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 Farkas István <is...@gmail.com> on 2012/10/17 14:58:09 UTC

WordDelimiterFilter and the dot character

Hello,

I've ran into an interesting problem. I am using Solr 3.5 on an Ubuntu 
server.

I have some data with a code field, which contains some identifiers 
(mostly) in the following format: E.123/2012.

I've set up a fieldType for this code field:

|<fieldType name="text_split" class="solr.TextField" positionIncrementGap="100">
<analyzer>
     <tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" splitOnNumerics="1" preserveOriginal="1" />
<filter class="solr.LowerCaseFilterFactory" />
   </analyzer>
</fieldType>
|

If I search for the exact code ("E.123/2012."), I will get the expected 
result. If I search for "123 2012", I also get the expected results. If 
I search for the "123/2012" string, the result set is empty. Tried it 
with catenateNumbers and catenateWords enabled, with the same results.

The interesting thing here is that using the field analysis tool, the 
123/2012 gives a match if I select the "highlight matches" option. But 
the same query yields nothing when I try to use it in the query debug 
tool in the Solr admin. The query works if I use a wilcard search 
(*123/2012*), but I would like to avoid that. What do I miss here?

Regards,
   Istvan


Re: WordDelimiterFilter and the dot character

Posted by dirk <ku...@googlemail.com>.
Hi Shawn,

Thank you very much, I will try it. 
Dirk



-----
erste Erfahrungen mit SOLR u. Vufind 
--
View this message in context: http://lucene.472066.n3.nabble.com/WordDelimiterFilter-and-the-dot-character-tp4014220p4014248.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: WordDelimiterFilter and the dot character

Posted by Shawn Heisey <so...@elyograg.org>.
On 10/17/2012 7:24 AM, dirk wrote:
> Hi,
>
> I had a very similar Problem while searching in a bibliographic field called
> "signatur". I could solve it by the help of additional Filterclasses. At the
> moment I use the following Filters. Then it works for me:
>
> ...
>          <charFilter class="solr.MappingCharFilterFactory"
> mapping="mapping-FoldToASCII.txt"/>
>          <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>          <filter class="solr.StopFilterFactory" ignoreCase="true"
> words="stopwords.txt" enablePositionIncrements="true" />
>          <filter class="solr.WordDelimiterFilterFactory"
> generateWordParts="1" generateNumberParts="1" catenateWords="1"
> catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
> 	<filter class="solr.LowerCaseFilterFactory"/>
>    	<filter class="solr.SnowballPorterFilterFactory" language="German" />
>    	<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
>    	<filter class="solr.ReversedWildcardFilterFactory" withOriginal="true"
> maxPosAsterisk="2" maxPosQuestion="1" minTrailing="2"
> maxFractionAsterisk="0"/>
> ...
> The MappingCharFilterFactory I have added in order to have a better support
> of german "Umlaute". Concerning the Wildcards:
> It is important that you use the ReversedWildcardFilterFactory only at index
> time. All other Filters I also use at query time.

This is unrelated to the original question, but I hope it's helpful.  
You can replace both MappingCharFilterFactory and LowerCaseFilterFactory 
with the following, at the current position of the lowercase filter.  It 
might produce better results, but you would have to reindex:

         <filter class="solr.ICUFoldingFilterFactory"/>

In order to do this, you must place the icu4j and lucene-icu 
(lucene-analyzers-icu in 4.x) jars in a lib folder accessed by Solr.  If 
you're using solr.xml (multicore) the best place is typically the 
sharedLib defined there.  If you're not using multicore, the lib folder 
would need to be defined in your solrconfig.xml.

http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.ICUFoldingFilterFactory

Thanks,
Shawn


Re: WordDelimiterFilter and the dot character

Posted by dirk <ku...@googlemail.com>.
Hi,

I had a very similar Problem while searching in a bibliographic field called
"signatur". I could solve it by the help of additional Filterclasses. At the
moment I use the following Filters. Then it works for me:

...
        <charFilter class="solr.MappingCharFilterFactory"
mapping="mapping-FoldToASCII.txt"/>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
        <filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" enablePositionIncrements="true" />
        <filter class="solr.WordDelimiterFilterFactory"
generateWordParts="1" generateNumberParts="1" catenateWords="1"
catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
	<filter class="solr.LowerCaseFilterFactory"/>
  	<filter class="solr.SnowballPorterFilterFactory" language="German" />   
  	<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>     
  	<filter class="solr.ReversedWildcardFilterFactory" withOriginal="true"
maxPosAsterisk="2" maxPosQuestion="1" minTrailing="2"
maxFractionAsterisk="0"/>
...
The MappingCharFilterFactory I have added in order to have a better support
of german "Umlaute". Concerning the Wildcards: 
It is important that you use the ReversedWildcardFilterFactory only at index
time. All other Filters I also use at query time.
Perhaps it could help.
Dirk



-----
erste Erfahrungen mit SOLR u. Vufind 
--
View this message in context: http://lucene.472066.n3.nabble.com/WordDelimiterFilter-and-the-dot-character-tp4014220p4014225.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: WordDelimiterFilter and the dot character

Posted by Jack Krupansky <ja...@basetechnology.com>.
Oh, and I forgot to mention that you should try your field type and query 
terms in the Solr Admin analyzer page. There you can see what sequence is 
generated for the query.

-- Jack Krupansky

-----Original Message----- 
From: Farkas István
Sent: Wednesday, October 17, 2012 9:33 AM
To: solr-user@lucene.apache.org
Subject: Re: WordDelimiterFilter and the dot character

Hm, that makes sense, thank you, I will try this one.

Regards,
   Istvan
> You need to have separate "index" and "query" analyzers for that field 
> type. The "query" analyzer would not have preserveOriginal="1", which 
> would generate an extra term that would not match the exact term sequence 
> that was indexed.
>
> A query of "123 2012" would not split any terms and hence not generate the 
> extra "preserved" term.
>
> But a query of "123/2012" would actually query "123/2012 123 2012", which 
> is not a term sequence that was indexed.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Farkas István
> Sent: Wednesday, October 17, 2012 8:58 AM
> To: solr-user@lucene.apache.org
> Subject: WordDelimiterFilter and the dot character
>
> Hello,
>
> I've ran into an interesting problem. I am using Solr 3.5 on an Ubuntu
> server.
>
> I have some data with a code field, which contains some identifiers
> (mostly) in the following format: E.123/2012.
>
> I've set up a fieldType for this code field:
>
> |<fieldType name="text_split" class="solr.TextField" 
> positionIncrementGap="100">
> <analyzer>
>     <tokenizer class="solr.WhitespaceTokenizerFactory" />
> <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" 
> generateNumberParts="1" splitOnNumerics="1" preserveOriginal="1" />
> <filter class="solr.LowerCaseFilterFactory" />
>   </analyzer>
> </fieldType>
> |
>
> If I search for the exact code ("E.123/2012."), I will get the expected
> result. If I search for "123 2012", I also get the expected results. If
> I search for the "123/2012" string, the result set is empty. Tried it
> with catenateNumbers and catenateWords enabled, with the same results.
>
> The interesting thing here is that using the field analysis tool, the
> 123/2012 gives a match if I select the "highlight matches" option. But
> the same query yields nothing when I try to use it in the query debug
> tool in the Solr admin. The query works if I use a wilcard search
> (*123/2012*), but I would like to avoid that. What do I miss here?
>
> Regards,
>   Istvan 


Re: WordDelimiterFilter and the dot character

Posted by Farkas István <is...@gmail.com>.
Hm, that makes sense, thank you, I will try this one.

Regards,
   Istvan
> You need to have separate "index" and "query" analyzers for that field 
> type. The "query" analyzer would not have preserveOriginal="1", which 
> would generate an extra term that would not match the exact term 
> sequence that was indexed.
>
> A query of "123 2012" would not split any terms and hence not generate 
> the extra "preserved" term.
>
> But a query of "123/2012" would actually query "123/2012 123 2012", 
> which is not a term sequence that was indexed.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Farkas István
> Sent: Wednesday, October 17, 2012 8:58 AM
> To: solr-user@lucene.apache.org
> Subject: WordDelimiterFilter and the dot character
>
> Hello,
>
> I've ran into an interesting problem. I am using Solr 3.5 on an Ubuntu
> server.
>
> I have some data with a code field, which contains some identifiers
> (mostly) in the following format: E.123/2012.
>
> I've set up a fieldType for this code field:
>
> |<fieldType name="text_split" class="solr.TextField" 
> positionIncrementGap="100">
> <analyzer>
>     <tokenizer class="solr.WhitespaceTokenizerFactory" />
> <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" 
> generateNumberParts="1" splitOnNumerics="1" preserveOriginal="1" />
> <filter class="solr.LowerCaseFilterFactory" />
>   </analyzer>
> </fieldType>
> |
>
> If I search for the exact code ("E.123/2012."), I will get the expected
> result. If I search for "123 2012", I also get the expected results. If
> I search for the "123/2012" string, the result set is empty. Tried it
> with catenateNumbers and catenateWords enabled, with the same results.
>
> The interesting thing here is that using the field analysis tool, the
> 123/2012 gives a match if I select the "highlight matches" option. But
> the same query yields nothing when I try to use it in the query debug
> tool in the Solr admin. The query works if I use a wilcard search
> (*123/2012*), but I would like to avoid that. What do I miss here?
>
> Regards,
>   Istvan


Re: WordDelimiterFilter and the dot character

Posted by Farkas István <is...@gmail.com>.
Just for the archives - the removal of the "preservereOriginal" from the 
"query" analizer solved my problem.

Thank you, Jack!

> You need to have separate "index" and "query" analyzers for that field 
> type. The "query" analyzer would not have preserveOriginal="1", which 
> would generate an extra term that would not match the exact term 
> sequence that was indexed.
>
> A query of "123 2012" would not split any terms and hence not generate 
> the extra "preserved" term.
>
> But a query of "123/2012" would actually query "123/2012 123 2012", 
> which is not a term sequence that was indexed.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Farkas István
> Sent: Wednesday, October 17, 2012 8:58 AM
> To: solr-user@lucene.apache.org
> Subject: WordDelimiterFilter and the dot character
>
> Hello,
>
> I've ran into an interesting problem. I am using Solr 3.5 on an Ubuntu
> server.
>
> I have some data with a code field, which contains some identifiers
> (mostly) in the following format: E.123/2012.
>
> I've set up a fieldType for this code field:
>
> |<fieldType name="text_split" class="solr.TextField" 
> positionIncrementGap="100">
> <analyzer>
>     <tokenizer class="solr.WhitespaceTokenizerFactory" />
> <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" 
> generateNumberParts="1" splitOnNumerics="1" preserveOriginal="1" />
> <filter class="solr.LowerCaseFilterFactory" />
>   </analyzer>
> </fieldType>
> |
>
> If I search for the exact code ("E.123/2012."), I will get the expected
> result. If I search for "123 2012", I also get the expected results. If
> I search for the "123/2012" string, the result set is empty. Tried it
> with catenateNumbers and catenateWords enabled, with the same results.
>
> The interesting thing here is that using the field analysis tool, the
> 123/2012 gives a match if I select the "highlight matches" option. But
> the same query yields nothing when I try to use it in the query debug
> tool in the Solr admin. The query works if I use a wilcard search
> (*123/2012*), but I would like to avoid that. What do I miss here?
>
> Regards,
>   Istvan


Re: WordDelimiterFilter and the dot character

Posted by Jack Krupansky <ja...@basetechnology.com>.
You need to have separate "index" and "query" analyzers for that field type. 
The "query" analyzer would not have preserveOriginal="1", which would 
generate an extra term that would not match the exact term sequence that was 
indexed.

A query of "123 2012" would not split any terms and hence not generate the 
extra "preserved" term.

But a query of "123/2012" would actually query "123/2012 123 2012", which is 
not a term sequence that was indexed.

-- Jack Krupansky

-----Original Message----- 
From: Farkas István
Sent: Wednesday, October 17, 2012 8:58 AM
To: solr-user@lucene.apache.org
Subject: WordDelimiterFilter and the dot character

Hello,

I've ran into an interesting problem. I am using Solr 3.5 on an Ubuntu
server.

I have some data with a code field, which contains some identifiers
(mostly) in the following format: E.123/2012.

I've set up a fieldType for this code field:

|<fieldType name="text_split" class="solr.TextField" 
positionIncrementGap="100">
<analyzer>
     <tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" 
generateNumberParts="1" splitOnNumerics="1" preserveOriginal="1" />
<filter class="solr.LowerCaseFilterFactory" />
   </analyzer>
</fieldType>
|

If I search for the exact code ("E.123/2012."), I will get the expected
result. If I search for "123 2012", I also get the expected results. If
I search for the "123/2012" string, the result set is empty. Tried it
with catenateNumbers and catenateWords enabled, with the same results.

The interesting thing here is that using the field analysis tool, the
123/2012 gives a match if I select the "highlight matches" option. But
the same query yields nothing when I try to use it in the query debug
tool in the Solr admin. The query works if I use a wilcard search
(*123/2012*), but I would like to avoid that. What do I miss here?

Regards,
   Istvan