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 crisfromnova <cr...@gmail.com> on 2011/09/14 10:42:29 UTC

Shouldn't ReversedWildcardFilterFactory resolve leadingWildcard?

Hi,

I use the next fieldType:
<fieldType name="text_general_rev" 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"/>
	        <filter class="solr.ReversedWildcardFilterFactory"
withOriginal="true"/>
	      </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" enablePositionIncrements="true" />
	        <filter class="solr.LowerCaseFilterFactory"/>
	        <filter class="solr.ReversedWildcardFilterFactory"
withOriginal="true"/>
	      </analyzer>
	    </fieldType>

What I want is to find autocar when I'm searching for "auto*", for example,
but no leading wildcard is returned. When I check fieldType with Analysis, 
I get this :


Index Analyzer
autocar
autocar
autocar
#1;racotua
autocar
Query Analyzer
car
car
car
car
#1;rac
car

So using for my search "car*" shouldn't become rac* and match racotua ?
Even if I search after "rac*" autocar is not found.

Using for search *car* is very expensive so I'm trying to generate the
reversed string and find it. There is a working configuration to accomplish
this?




--
View this message in context: http://lucene.472066.n3.nabble.com/Shouldn-t-ReversedWildcardFilterFactory-resolve-leadingWildcard-tp3335240p3335240.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Shouldn't ReversedWildcardFilterFactory resolve leadingWildcard?

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
"auto*" is not a leading wildcard query, a leading wildcard query would be
"*car". Wildcard queries in general will take more time than regular
queries, the more close the wildcard is to the first character, the more
expensive the query is.
With a regular field type, Solr will allow wildcards (not with dismax) like
"auto*", but not leading wildcard queries like "*car".

The ReverseWilcardFilter is there for allowing leading wildcards on
searches. It only needs to be added at index time (not at query time). When
using this field type, all the terms at index time will be reversed like you
showed on your example, adding an *impossible character* at the beginning of
the term to prevent it to match regular terms.

'autocar' will be indexed as 'autocar' and '#1;racotua' (see '#1;', that's
the impossible character).

When you search for 'auto*', Solr will resolve the query as always but if
you search for '*car', the query parser (not any analysis filter, that's why
you don't need to add the filter on query-time) will invert that term and
add the 'impossible character' at the beginning, like '#1;rac*'. That's why
'#1;racotuar' should match the query.

>From your configuration, if you remove the filter at query-time it should
work.

Regards,

Tomás

On Wed, Sep 14, 2011 at 6:26 AM, crisfromnova <cr...@gmail.com>wrote:

> I found a partial solution.
> Using ReverseStringFilterFactory instead ReverseWildcardFilterFactory and
> searching after "rac*" will find "autocar" for example.
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Shouldn-t-ReversedWildcardFilterFactory-resolve-leadingWildcard-tp3335240p3335307.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Shouldn't ReversedWildcardFilterFactory resolve leadingWildcard?

Posted by crisfromnova <cr...@gmail.com>.
I found a partial solution.
Using ReverseStringFilterFactory instead ReverseWildcardFilterFactory and
searching after "rac*" will find "autocar" for example.

--
View this message in context: http://lucene.472066.n3.nabble.com/Shouldn-t-ReversedWildcardFilterFactory-resolve-leadingWildcard-tp3335240p3335307.html
Sent from the Solr - User mailing list archive at Nabble.com.