1

We are trying to use solr on our website as a search engine , but we have a problem , we can not sort the suggestions by the number of sales.

I tried the components Facet, Terms, FreeTextLookupFactory and the spellcheck component, but in none of the above components are able to get the results that I want.

The most important thing that I would understand its if we can sort the suggestion for a weight chosen by us.

The version of solr we are using is the 5.0.

schema.xml:

<field name="name_complete" type="text_shingle" indexed="true" stored="true" required="false" multiValued="false" omitTermFreqAndPositions="true"/>

<fieldType name="text_shingle" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer> 
        <tokenizer class="solr.StandardTokenizerFactory"/> 
        <filter class="solr.LowerCaseFilterFactory"/> 
        <filter class="solr.ShingleFilterFactory" maxShingleSize="4" outputUnigrams="true"/> 
    </analyzer> 
</fieldType>

solrconfig.xml FreeTextLookupFactory:

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">suggest_product_free</str>
        <str name="lookupImpl">FreeTextLookupFactory</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">name_complete</str>
        <str name="indexPath">suggest_product_free</str>
        <str name="weightField">n_sales</str>
        <str name="buildOnCommit">true</str>

        <str name="suggestFreeTextAnalyzerFieldType">text_shingle</str>
    <int name="ngrams">3</int>
    </lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="echoParams">explicit</str>
        <str name="wt">json</str>
        <str name="indent">true</str>
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
    </lst>

    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

spellcheck:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <lst name="spellchecker">
        <str name="queryAnalyzerFieldType">text_shingle</str>
        <str name="name">autocomplete</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
        <str name="field">name_complete</str>
        <str name="buildOnCommit">true</str>
        <float name="threshold">0.005</float>
       <str name="spellcheckIndexDir">./suggester_autocomplete</str>
    </lst>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <!-- Solr will use suggestions from both the 'default' spellchecker
           and from the 'wordbreak' spellchecker and combine them.
           collations (re-written queries) can include a combination of
           corrections from both spellcheckers -->
        <str name="spellcheck">true</str>
        <str name="spellcheck.count">10</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.dictionary">autocomplete</str>
        <!--str name="spellcheck.dictionary">wordbreak</str>
        <str name="spellcheck.extendedResults">true</str>
        <str name="spellcheck.alternativeTermCount">5</str>
        <str name="spellcheck.maxResultsForSuggest">5</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.collateExtendedResults">true</str>
        <str name="spellcheck.maxCollationTries">10</str>
        <str name="spellcheck.maxCollations">5</str-->
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>

any ideas how I can make to order the suggestion for the weight?

Thanks to all and have a nice day.

example: assume that I have these saved values on solr:

1: Reflex canon eos 7d (weight: 1)
2: Reflex canon eos 6d (weight: 2)
3: Reflex canon eos 70d (weight: 3)

and requested the string 'can'. the result that I want:

canon eos
canon eos 70d
canon eos 6d
canon eos 7d

in practice would that it were a autocomplete that I can order for the weight.

Phuc Thai
  • 718
  • 7
  • 17
Elson
  • 11
  • 3
  • You should include the request and the response as well - and whether you're getting a response from the suggester at all. The [Example in the manual](https://cwiki.apache.org/confluence/display/solr/Suggester#Suggester-ExampleUsages) includes everything you should need to set up a suggester like you want, but you should probably start with the same values for lookupimpl etc. as well. – MatsLindh Mar 14 '15 at 17:30
  • Hello, I had seen the example, however, the only thing that I would suggest the words (autocomplete), but at the same time I would order for the weight (give a priority to word suggestions). Thank You. – Elson Mar 14 '15 at 19:22
  • Yes, the example has that. You'll have to give more information, such as an example of data, your request, the response, etc. The example retrieves the weight from a separate column as far as I understand. – MatsLindh Mar 15 '15 at 12:57

0 Answers0