lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tejas Bhanushali <contact.tejasbhanush...@gmail.com>
Subject Re: Getting duplicate output while doing auto suggestion based on multiple filed using copy filed in solr 5.5
Date Mon, 25 Apr 2016 18:39:37 GMT
Hi Team ,

Please follow the below steps to reproduce this issue.for that  you to
change the existing config file under the
directory solr-5.5.0\server\solr\configsets\sample_techproducts_configs\conf
.

Note:- if you see the config i have used the "AnalyzingInfixLookupFactory"
instead of "FuzzyLookupFactory" for infix search .

Step 1:- First replace the existing "Suggest" component in solrconfig.xml
as mention below.

  <searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
      <str name="name">mySuggester</str>
     <!--<str name="lookupImpl">FuzzyLookupFactory</str>
      <str name="storeDir">suggester_fuzzy_dir</str>-->
       <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
      <str name="indexPath">suggester_infix_dir</str>
       <str name="dictionaryImpl">DocumentDictionaryFactory</str>
      <str name="field">suggest_text</str>
       <str name="weightField">price</str>
      <str name="suggestAnalyzerFieldType">text_auto</str>
      <str name="queryAnalyzerFieldType">text_auto</str>
      <str name="buildOnStartup">false</str>
   <str name="buildOnCommit">false</str>
    </lst>
  </searchComponent>

  <requestHandler name="/suggest" class="solr.SearchHandler"
                  startup="lazy" >
    <lst name="defaults">
      <str name="suggest">true</str>
      <str name="suggest.count">10</str>
  <!--<str name="suggest.dictionary">mySuggester</str>-->
  <str name="suggest.onlyMorePopular">true</str>
   <str name="suggest.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

Step2:- Add new field  into managed-schema for auto suggetion .

    <field name="suggest_text" type="text_auto" indexed="true"
stored="true" multiValued="true"/>

Step3:- i have provided suggestion  based on multiple fields i.e. on
cat,name and manu

    <copyField source="cat" dest="suggest_text"/>
    <copyField source="name" dest="suggest_text"/>
<copyField source="manu" dest="suggest_text"/>
Step4:- add below field type into solrconfig.xml. please note that i have
used NgramTokenizer to provide suggetion based on user type character into
search box.
   eg. suppose user type "compu" then it should get suggetion like
 "electronics and computer1"

<fieldType name="text_auto" class="solr.TextField"
positionIncrementGap="100">

<analyzer type="index">
<tokenizer class="solr.NGramTokenizerFactory" minGramSize="2"
maxGramSize="30"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.EdgeNGramTokenizerFactory" minGramSize="2"
maxGramSize="10"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

Step 5:- run the solr by using existing techproducts example
bin\solr -e techproducts

Step5:- Run the below command to build the schema
curl "http://localhost:8983/solr/techproducts/suggest?suggest.dic
tionary=mySuggester&suggest=true&suggest.build=true&wt=json"

Step6:- finally run the url like:-
curl "http://localhost:8983/solr/techproducts/suggest?wt=json&ind
ent=true&suggest.dictionary=mySuggester&suggest=true&avoidDuplicate=0&suggest.q=
electro"

Step 7:- you will get below response:-

{
  "responseHeader":{
    "status":0,
    "QTime":15},
  "suggest":{"mySuggester":{
      "elec":{
        "numFound":10,
        "suggestions":[{
            "term":"<b>el</b>ectronics and computer1",
            "weight":2199,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":649,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":479,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":399,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":350,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":329,
            "payload":""},
          {
            "term":"<b>el</b>ectronics and stuff2",
            "weight":279,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":185,
            "payload":""},
          {
            "term":"<b>el</b>ectronics",
            "weight":179,
            "payload":""},
          {
            "term":"Samsung Electronics Co. Ltd.",
            "weight":92,
            "payload":""}]}}}}

if you see the response then you will find the word "electronics" getting
repeating by 7 times.

PFA file for your reference if you unable to config as i mention above.

Please advice how to resolve this issue .

Thanks & Regards,
Tejas

On Mon, Apr 18, 2016 at 11:12 PM, Tejas Bhanushali <
contact.tejasbhanushali@gmail.com> wrote:

> HI Team,
>
> I tried to run the same example as suggested by Chris Hostetter and i get
> to know it's working fine for single field, but my requirement is it should
> suggest based on multiple fields .i.e not only on "cat" field but it should
> suggest based on few other fields like 'name','manu' etc. and due to
> fuzzylookupfactory it's give suggestion based on starting characters, not
> if users type any middle character of phrase eg. i tried with searching by
> 'stuff2' of 'electronics and stuff2' cat .
>
> curl 'http://localhost:8983/solr/techproducts/suggest?wt=json&ind
> ent=true&suggest.dictionary=mySuggester&suggest=true&suggest.q=stuff'
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":2},
>   "suggest":{"mySuggester":{
>       "stuff":{
>         "numFound":0,
>         "suggestions":[]}}}}
>
> On Fri, Apr 15, 2016 at 11:18 PM, Tejas Bhanushali <
> contact.tejasbhanushali@gmail.com> wrote:
>
>> Hi Team,
>>
>> Im getting the duplicate result when i do auto suggestion based on
>> multiple filed by using copy filed . i have below table configuration .
>>
>> Segment -- have multiple category -- have multiple sub category -- have
>> multiple products.
>>
>> suggestion are given based on
>> segment name, category name, sub category name and product name.
>>
>> below is output .
>>
>> ---------------
>>
>> {
>>   "responseHeader": {
>>     "status": 0,
>>     "QTime": 1375
>>   },
>>   "command": "build",
>>   "suggest": {
>>     "mySuggester": {
>>       "Fruit": {
>>         "numFound": 10,
>>         "suggestions": [
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 1000,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 1000,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 980,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 980,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 800,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 588,
>>             "payload": ""
>>           },
>>           {
>>             "term": "Cut <b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           }
>>         ]
>>       }
>>     }
>>   }
>> }
>>
>> --
>> Thanks & Regards,
>>
>> Tejas Bhanushali
>>
>
>
>
> --
> Thanks & Regards,
>
> Tejas Bhanushali
>



-- 
Thanks & Regards,

Tejas Bhanushali

On Mon, Apr 18, 2016 at 11:12 PM, Tejas Bhanushali <
contact.tejasbhanushali@gmail.com> wrote:

> HI Team,
>
> I tried to run the same example as suggested by Chris Hostetter and i get
> to know it's working fine for single field, but my requirement is it should
> suggest based on multiple fields .i.e not only on "cat" field but it should
> suggest based on few other fields like 'name','manu' etc. and due to
> fuzzylookupfactory it's give suggestion based on starting characters, not
> if users type any middle character of phrase eg. i tried with searching by
> 'stuff2' of 'electronics and stuff2' cat .
>
> curl 'http://localhost:8983/solr/techproducts/suggest?wt=json&ind
> ent=true&suggest.dictionary=mySuggester&suggest=true&suggest.q=stuff'
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":2},
>   "suggest":{"mySuggester":{
>       "stuff":{
>         "numFound":0,
>         "suggestions":[]}}}}
>
> On Fri, Apr 15, 2016 at 11:18 PM, Tejas Bhanushali <
> contact.tejasbhanushali@gmail.com> wrote:
>
>> Hi Team,
>>
>> Im getting the duplicate result when i do auto suggestion based on
>> multiple filed by using copy filed . i have below table configuration .
>>
>> Segment -- have multiple category -- have multiple sub category -- have
>> multiple products.
>>
>> suggestion are given based on
>> segment name, category name, sub category name and product name.
>>
>> below is output .
>>
>> ---------------
>>
>> {
>>   "responseHeader": {
>>     "status": 0,
>>     "QTime": 1375
>>   },
>>   "command": "build",
>>   "suggest": {
>>     "mySuggester": {
>>       "Fruit": {
>>         "numFound": 10,
>>         "suggestions": [
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 1000,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 1000,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 980,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 980,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 800,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 588,
>>             "payload": ""
>>           },
>>           {
>>             "term": "Cut <b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s & Vegetables",
>>             "weight": 456,
>>             "payload": ""
>>           },
>>           {
>>             "term": "<b>Fruit</b>s",
>>             "weight": 456,
>>             "payload": ""
>>           }
>>         ]
>>       }
>>     }
>>   }
>> }
>>
>> --
>> Thanks & Regards,
>>
>> Tejas Bhanushali
>>
>
>
>
> --
> Thanks & Regards,
>
> Tejas Bhanushali
>



-- 
Thanks & Regards,

Tejas Bhanushali

Mime
View raw message