简体   繁体   English

重视包含单词接近度+太阳+黑子的文档

[英]give importance to documents which contains the word proximity + solr + sunspot

I am working on rails application and which is based on Apache Solr search engine and we are using Sunspot gem. 我正在使用基于Apache Solr搜索引擎的Rails应用程序,并且正在使用Sunspot gem。 But I am facing one problem, If I search query house rent then its giving me thousands of results by using and query . 但是我面临一个问题,如果我搜索查询house rent那么它会通过使用and query给我成千上万个结果。 But the results what I am getting are not relevant. 但是我得到的结果并不相关。

I am expecting the documents which contains the house and rent words near to each other, those documents should come on top. 我希望包含房屋和租赁字词的文件彼此靠近,这些文件应该放在最上面。 But for now the documents which contains more number of house and rent documents are coming on top. 但是目前,包含更多房屋和租金文件的文件排在最前面。 But there is no any word proximity. 但是没有任何单词接近。

My schema.xml contains following definition: 我的schema.xml包含以下定义:

<fieldType name="text" class="solr.TextField" omitNorms="false">
  <analyzer>
    <tokenizer class="solr.PatternTokenizerFactory" pattern="[\s,\.;\(\)]+"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
</fieldType>

To achieve this what changes are need to do? 要实现这一点,需要做哪些改变? or any filter are necessary to add for this? 或为此添加任何过滤器?

You can try this 你可以试试这个

<fieldType name="shingleString" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
      <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.ShingleFilterFactory" outputUnigrams="true" outputUnigramIfNoNgram="true" maxShingleSize="99"/>
        <filter class="solr.PositionFilterFactory" />
      </analyzer>
    </fieldType>

使用词组字段来增强它们,或者您可以尝试增强术语如"house rent"~5

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

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