You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Andy Newby <an...@gmail.com> on 2011/07/26 16:59:02 UTC

Cant get Synonym working

Hi,

I'm coing back to trying to get the Synonynms working (alongside the
spellchecker). Here is what I have:

<fieldType name="spell" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>

Then in synonyms.txt, I have:

pixima => pixma
cellpne => cellphone
computer => laptop

aaaa, car, food, hhhh

aaaaaaaaaaaaaaaaaaa, food

However, after restarting Solr and then trying a search for
"aaaaaaaaaaaaaaaaaaa" , my test result which contains "food" in, never seems
to come up

Anyone got any ideas?

The annoying thing is that it works fine on a 2nd "dev" install I have (much
simpler, and not using multicore), but using the exact same fieldType setup.

Can anyone shed any light?

TIA!
-- 
Andy Newby
andy@ultranerds.com

Re: Cant get Synonym working

Posted by Emmanuel Espina <es...@gmail.com>.
Well it appears to be some issue with the analysis. You can check the
http://localhost:8983/solr/admin/analysis.jsp (the admin page of your
instance, the analysis section) to see how the analysis is applied and see
the end result of "aaaaaaaaaaa"
You should work with the index and the query analysis too see if what you
wanted is actually what is being performed in Solr.

If you search for "food", does Solr find the correct documents?

Does your other instance (the one that works fine) contains the exact same
documents? Are the indexes identical? remember that after applying changes
to the index analysis chain you must re index all the documents again,
otherwise, the already indexed documents will have the terms with the
previous analysis applied, restarting solr after changes in the indexing
analysis chain is not enough.

Thanks
Emmanuel

2011/7/26 Andy Newby <an...@gmail.com>

> Hi,
>
> I'm coing back to trying to get the Synonynms working (alongside the
> spellchecker). Here is what I have:
>
> <fieldType name="spell" class="solr.TextField" positionIncrementGap="100">
>  <analyzer type="index">
>    <tokenizer class="solr.StandardTokenizerFactory"/>
>    <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt"/>
>    <filter class="solr.StandardFilterFactory"/>
>    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>  </analyzer>
>  <analyzer type="query">
>    <tokenizer class="solr.StandardTokenizerFactory"/>
>    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt"
> ignoreCase="true" expand="true"/>
>    <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt"/>
>    <filter class="solr.StandardFilterFactory"/>
>    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>  </analyzer>
> </fieldType>
>
> Then in synonyms.txt, I have:
>
> pixima => pixma
> cellpne => cellphone
> computer => laptop
>
> aaaa, car, food, hhhh
>
> aaaaaaaaaaaaaaaaaaa, food
>
> However, after restarting Solr and then trying a search for
> "aaaaaaaaaaaaaaaaaaa" , my test result which contains "food" in, never
> seems
> to come up
>
> Anyone got any ideas?
>
> The annoying thing is that it works fine on a 2nd "dev" install I have
> (much
> simpler, and not using multicore), but using the exact same fieldType
> setup.
>
> Can anyone shed any light?
>
> TIA!
> --
> Andy Newby
> andy@ultranerds.com
>