0

I did one work around to get all documents that contains "Good" or "Microwave" or "Good Microwave",if i will pass "Good Microwave" as q parameter please guide me wheather i am going in right direction or not.

I defined two field type(text_general and shingleString) in my schema like below

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />        
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />        
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

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

then while indexing i am adding all these field to two different copy fields like below.

<field name="SearchableField" type="shingleString" indexed="true" stored="false" multiValued="true"/>
    <copyField source="ProductName" dest="SearchableField"/>
     <copyField source="ProductDesription" dest="SearchableField"/>
    <copyField source="Product Feedback" dest="SearchableField"/>

<field name="SearchableField1" type="text_general" indexed="true" stored="false" multiValued="true"/>
    <copyField source="ProductName" dest="SearchableField1"/>
     <copyField source="ProductDesription" dest="SearchableField1"/>
    <copyField source="Product Feedback" dest="SearchableField1"/>

And now if i am querying on both the fields SearchableField and SearchableField1 i am getting all the documents which contains "Good" or "Microwave" or "Good Microwave". Below is the query i am using to get all the documents. q=SearchableField%3AGood+Microwave%0ASearchableField1%3AGood+Microwave

But the documents containing the whole phrase "Good Microwave",are getting a very low score. Can anybody guide me to get a higher score on those documents which contains the whole phrase if at all my approach is correct ?

Or can anybody guide me to achieve this ?

Ppm
  • 162
  • 1
  • 13

2 Answers2

0

Hello frnd you can use simple query using 'suggester component' request handler with field type shingleString for searching phrase.just u have to concentrate on ur query syntax......

 http://localhost:8983/solr/suggest?wt=xml&indent=true&spellcheck=true&spellcheck.q=usrsearchphrase


 <fieldType name="shingleString" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
  <analyzer type="index">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.PositionFilterFactory" />
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.ShingleFilterFactory" outputUnigrams="true" outputUnigramIfNoNgram="true" maxShingleSize="99"/>
    <filter class="solr.PositionFilterFactory" />
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>
Developer Desk
  • 2,294
  • 8
  • 36
  • 77
  • Hi I did one work around.I have edited the question.Please tell me is that a correct approach ? – Ppm Feb 10 '13 at 17:37
0

If you have a field of type 'text_general', searching for:q=good microwave Will find any documents with either 'good' or 'microwave' in them. Searching for:q="good microwave" will find any documents that contain both terms next to each other. q="good microwave"^5 good microwave will find any documents that contain either term but will boost documents that contain the terms next to each other.

Ppm
  • 162
  • 1
  • 13