简体   繁体   English

SOLR 5.1 中的精确匹配

[英]Exact Match in SOLR 5.1

I have setup Solr 5.1.0 with proper data importation from MYSQL database.我已经设置了 Solr 5.1.0,并从 MYSQL 数据库导入了正确的数据。 It is working good.它运行良好。

But I want exact match results or relevant to that only.但我想要精确匹配结果或仅与此相关。

like,喜欢,

Dancers in Mumbai

It gives all results which contains "dancers + mumbai" and only "dancers" + only "mumbai" keywords.它给出包含“舞者+孟买”和仅“舞者”+仅“孟买”关键字的所有结果。 I want result which must contains only "dancers + mumbai" not others.我想要的结果必须只包含“舞者+孟买”而不是其他人。

This is not a complete answer, but it's the direction I'm trying to take with a similar problem.这不是一个完整的答案,但它是我试图解决类似问题的方向。 Comments are very welcome.非常欢迎评论。

Step 1: Implement multiple Solr cores, core 1 is "jobs" (dancers/lawyers/etc), and core 2 is "cities" (mumbai/chennai/etc).第一步:实现多个Solr核心,核心1是“工作”(舞者/律师/等),核心2是“城市”(孟买/钦奈/等)。

Step 2: Query each core for exact matches, so implement the KeywordTokenizerFactory on the relevant field to find exact matches only.第 2 步:查询每个核心的精确匹配,因此在相关字段上实现 KeywordTokenizerFactory 以仅查找精确匹配。 This will give you all the matches accross cores (eg jobs: dancers and cities:mumbai).这将为您提供跨核心的所有匹配项(例如工作:舞者和城市:孟买)。

Step 3: Perform your general query using EDisMax for a user-friendly search (eg searching for "dancers in mumbai" accross many fields), and use the boost field to boost the jobs/cities found in the earlier query.第 3 步:使用 EDisMax 执行您的一般查询以进行用户友好的搜索(例如在许多领域中搜索“孟买的舞者”),并使用 boost 字段来提升在早期查询中找到的工作/城市。

I would love to know if there is a better way of doing something this elaborate, but I have not found it yet.我很想知道是否有更好的方法来做这么复杂的事情,但我还没有找到。 Hope it helps.希望能帮助到你。

Using required terms like: +dancers +mumbia使用必需的术语,例如: +dancers +mumbia

Or a phrase query: "dancers in mumbia"或短语查询:“孟比亚的舞者”

Would work.会工作。

You can also set the default operator for your query to be "AND", using the q.op parameter .您还可以使用q.op参数将查询的默认运算符设置为“AND”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM