我对 Apache Solr 进行了一些分析,它非常适合从各种来源搜索数据。 我面临的问题是如何标准化我的搜索语法并将搜索文本翻译为 Solr 查询。
我有三种类型的文件/数据库表可供搜索 - 即客户、行业和单位。搜索框中的第一个关键字应该是这三个关键字中的任何一个。之后,用户可以定义一组固定的标准:
Metrics : 0 or many (ex, exposure, income, revenue, loan_amt etc)
Dimension : 0 or many (Geography, region, etc)
示例:
customer - Returns all customer data from customer core
customer income from Asia - Returns all customer income details who belongs to Asia
customer income revenue from Asia - Returns all customer income and revenue details who belongs to Asia
如何将上述自然语言搜索文本翻译为 solr 查询? 我可以像这样修复 Solr 中的文本语法吗 第一个关键字应该是客户/行业/单位, 第二个键值是一个或多个区域/地理位置 然后是度量值。
我不是在寻找类似谷歌的搜索,而是在寻找用户知道要搜索什么的有限搜索。
最佳答案
严格来说,这似乎不是 Solr 问题。作为第一步,您可能想要定义 context-free grammar (CFG,类型 2 语法)基于您输入的特定产生规则。这将为您提供一些可靠的语法规则供您使用。在此基础上,您可以为自然语言输入创建一个解析器,并将生成的解析树映射到 Solr 中的关键字搜索。
关于java - 使用 Apache Solr 的半自然语言搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35866603/