简体   繁体   English

具有不同分析器的多个字段的 Solr 默认搜索字段

[英]Solr default search field for multiple fields which has different analyzers

I have a document which has title , stockCode , category fields.我有一个包含titlestockCodecategory字段的文档。

I have different field types (and analysis chains) for each.我有不同的字段类型(和分析链)。 For instance title has EdgeNGram 2 to 20, category has EdgeNGram 3 to 10 with different range and stockCode just has lowercase filter.例如, title有 EdgeNGram 2 到 20, category有 EdgeNGram 3 到 10,范围不同, stockCode只有小写过滤器。

So that, I don't want to search from documents with keyword "sample" with building the query like title:sample OR stockCode:sample OR category:sample .因此,我不想通过构建类似title:sample OR stockCode:sample OR category:sample的查询从带有关键字“sample”的文档中进行搜索。

I'd like to search with just " q=sample ".只想用“ q=sample进行搜索。

I copied my fields to text but It does not work.我将我的字段复制到文本,但它不起作用。 Because all fields analyzed as same.因为所有字段都分析为相同。 But I don't want to index stockCode as EdgeNGram or any other filters.但我不想将 stockCode 索引为 EdgeNGram 或任何其他过滤器。 I'd like to index my fields as I configured and I'd like to search a keyword over them base on my indexes.我想按照我的配置对我的字段进行索引,我想根据我的索引在它们上搜索关键字。

I've been researching about that for three days, and Solr has a little bit poor documentation.我已经研究了三天,Solr 的文档有点差。

You can use the edismax handler, as this will allow you to give a list of fields to query and supply the query by itself.您可以使用edismax处理程序,因为这将允许您提供要查询的字段列表并自行提供查询。 You can also give separate weights to each field for scoring them differently.您还可以为每个字段赋予单独的权重,以对它们进行不同的评分。

defType=edismax&q=sample&qf=title^10 stockCode category

.. will search for sample in each of the three fields, giving a 10x boost to any hits in the title field. .. 将在三个字段中的每一个中搜索sample ,使title字段中的任何命中率提高 10 倍。

You can find the documentation about the edismax query parser under Searching in the reference guide.您可以在参考指南的Searching找到有关 edismax 查询解析器的文档

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

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