0

I am working on rails application and which is based on Apache Solr search engine and we are using 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. 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:

<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?

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
Deepti Kakade
  • 3,053
  • 3
  • 19
  • 30

2 Answers2

0

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>
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • not working the above solution. Getting the same result – Deepti Kakade Jun 11 '15 at 07:04
  • could you please elaborate here...what are your indexing text and what is the search text? it could ease our task... – Abhijit Bashetti Jun 11 '15 at 07:12
  • my search text is `housing rent` , and I am getting the results, but order of result is not correct, the first document contains both words, but word gap is more, and my 7th document contains house rent and there is 0 word gap. So I want my 7th document should appear on top than the 1st document. – Deepti Kakade Jun 11 '15 at 07:16
0

Use phrase fields and boost them or you can try terms boosting like "house rent"~5

Datt
  • 851
  • 9
  • 21