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 dbashford <db...@hotmail.com> on 2010/06/29 23:56:57 UTC

Leading Wildcard query strangeness

We've got an app in production that executes leading wildcard queries just
fine.

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">1298</int>
  <lst name="params">
    <str name="q">title:*news</str>
  </lst>
</lst>
<result name="response" numFound="5514" start="0">

The same app in dev/qa has undergone a major schema/solrconfig overhaul,
including introducing multiple cores, and leading wildcard queries no longer
work...

org.apache.lucene.queryParser.ParseException: Cannot parse 'title:*news':
'*' or '?' not allowed as first character in WildcardQuery

All fields are exhibiting this behavior, whether their fieldType changed or
not.  In the case of title, it did not change.

I intend to pour over the changes to see what might have screwed things up,
but is there some simple setting somewhere that turns this on and off?  I
know https://issues.apache.org/jira/browse/SOLR-218 deals with this, but I
have to think there's some other way to do it or else our prod app wouldn't
be successfully executing Wildcard queries.  Is there another way without
QueryParser.setAllowLeadingWildcard(true)?

(Running 1.4 in all environments, although "newer" versions of 1.4
(downloaded more recently) in dev and qa.)

Thoughts?


-- 
View this message in context: http://lucene.472066.n3.nabble.com/Leading-Wildcard-query-strangeness-tp931809p931809.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Leading Wildcard query strangeness

Posted by Chris Hostetter <ho...@fucit.org>.
: In the default schema.xml, only text_rev fieldType has 
: ReversedWildcardFilterFactory. The query below (manu_exact:*in) returns 
: two documents (whose manu_exact is Belkin).
: 
: Am i missing something?
: 
: http://localhost:8983/solr/select/?q=manu_exact%3A*in&version=2.2&start=0&rows=10&indent=on&fl=manu_exact

No, i was mistaken -- i'm sorry.  

You were corect before about the behavior: In Solr 1.4, if you have 
ReversedWildcardFilterFactory on any field type in your schema.xml then 
you can use leading wildcard queries on any field -- but i don't believe 
this is intentional, it looks like a buggy side effect of how 
SolrQueryParser subclasses QueryParser.

I've opeend a Jira issue to track how this should be dealt with...

https://issues.apache.org/jira/browse/SOLR-1982




-Hoss


Re: Leading Wildcard query strangeness

Posted by Ahmet Arslan <io...@yahoo.com>.
> that's how SolrQueryParser works at the moment, yes.

In the default schema.xml, only text_rev fieldType has ReversedWildcardFilterFactory. The query below (manu_exact:*in) returns two documents (whose manu_exact is Belkin). 

Am i missing something?

http://localhost:8983/solr/select/?q=manu_exact%3A*in&version=2.2&start=0&rows=10&indent=on&fl=manu_exact



      

Re: Leading Wildcard query strangeness

Posted by Chris Hostetter <ho...@fucit.org>.
: Does this mean leading * operator can only be used with fields whose 
: fieldType definition has ReversedWildcardFilterFactory at index time?

that's how SolrQueryParser works at the moment, yes.



-Hoss


Re: Leading Wildcard query strangeness

Posted by Ahmet Arslan <io...@yahoo.com>.
> that's not correct....  what SolrQueryParser does is
> check which field 
> types use ReversedWildcardFilterFactory at indexing time,
> and then when 
> parsing queries, it allows fields that use field types to
> be parsed with a  leading wildcard.

Does this mean leading * operator can only be used with fields whose fieldType definition has ReversedWildcardFilterFactory at index time?


      

Re: Leading Wildcard query strangeness

Posted by Chris Hostetter <ho...@fucit.org>.
: > I'm going to guess that is what you meant, that the very
: > presence of the
: > filter in the schema, whether it is used or not, allows you
: > to do wildcard
: > searches.
: 
: Exactly.

that's not correct....  what SolrQueryParser does is check which field 
types use ReversedWildcardFilterFactory at indexing time, and then when 
parsing queries, it allows fields that use field types to be parsed with a 
leading wildcard.

-Hoss


Re: Leading Wildcard query strangeness

Posted by Ahmet Arslan <io...@yahoo.com>.
> I'm going to guess that is what you meant, that the very
> presence of the
> filter in the schema, whether it is used or not, allows you
> to do wildcard
> searches.

Exactly.

> Is that documented anywhere and I just missed it?  I'm
> sure it is.

I knew it from source code of SolrQueryParser.
protected void checkAllowLeadingWildcards()
I didn't see anything in wiki about it.


      

Re: Leading Wildcard query strangeness

Posted by dbashford <db...@hotmail.com>.
An update in case someone stumbles upon this...

At first I thought you mean the fields I intend to do leading wildcard
searches on needed to have ReversedWildcardFilterFactory on them.  But that
didn't make sense because our prod app isn't using that at all.

But our prod app does have the "text_rev" still in it from the example
schema we copied over and used as our template.  One of the things we've
done in dev is clean that out and try to get down to what we are using. So I
tossed the text_rev back into the schema.xml, didn't actually use that field
type for any fields, and now I can do leading wildcard searches again.

I'm going to guess that is what you meant, that the very presence of the
filter in the schema, whether it is used or not, allows you to do wildcard
searches.

Is that documented anywhere and I just missed it?  I'm sure it is.
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Leading-Wildcard-query-strangeness-tp931809p933600.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Leading Wildcard query strangeness

Posted by Ahmet Arslan <io...@yahoo.com>.
> We've got an app in production that executes leading
> wildcard queries just
> fine.
> 
> <lst name="responseHeader">
>   <int name="status">0</int>
>   <int name="QTime">1298</int>
>   <lst name="params">
>     <str name="q">title:*news</str>
>   </lst>
> </lst>
> <result name="response" numFound="5514" start="0">
> 
> The same app in dev/qa has undergone a major
> schema/solrconfig overhaul,
> including introducing multiple cores, and leading wildcard
> queries no longer work...

IIf you have ReversedWildcardFilterFactory in your schema.xml you can use leading * operator.