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 Mohamed Parvez <pa...@gmail.com> on 2009/09/05 00:40:03 UTC

Filter query to check for not null filed

Say i have 3 fields, named field1,field2 and field3

I want to query all records that have "xxx" in field1 and filed3 should not
be null

I tried
1] q=field1:xxx&fq=?
Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
parse 'title:?': '*' or '?' not allowed as first character in WildcardQuery

2] q=filed1:xxx&fq=-x
Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
parse 'title:-smb': Encountered " "-" "- "" at line 1, column 6. Was
expecting one of: "(" ... "*" ... ... ... ... ... "[" ... "{" ... ...


Any suggestions?

----
Thanks/Regards,
Parvez

Re: Filter query to check for not null filed

Posted by Lance Norskog <go...@gmail.com>.
In the standard query parser, you would use:

q=field1:xxx+field3:[* TO *]

You cannot use * or ? as the first letter of a query term. The [* TO *]
syntax is a range query. Using * at both ends means "any to any".

On Fri, Sep 4, 2009 at 3:40 PM, Mohamed Parvez <pa...@gmail.com> wrote:

> Say i have 3 fields, named field1,field2 and field3
>
> I want to query all records that have "xxx" in field1 and filed3 should not
> be null
>
> I tried
> 1] q=field1:xxx&fq=?
> Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
> parse 'title:?': '*' or '?' not allowed as first character in WildcardQuery
>
> 2] q=filed1:xxx&fq=-x
> Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
> parse 'title:-smb': Encountered " "-" "- "" at line 1, column 6. Was
> expecting one of: "(" ... "*" ... ... ... ... ... "[" ... "{" ... ...
>
>
> Any suggestions?
>
> ----
> Thanks/Regards,
> Parvez
>



-- 
Lance Norskog
goksron@gmail.com

Re: Filter query to check for not null filed

Posted by Avlesh Singh <av...@gmail.com>.
Escape your special characters. q=field:\? and q=field:\- should work fine.

Cheers
Avlesh

On Sat, Sep 5, 2009 at 4:10 AM, Mohamed Parvez <pa...@gmail.com> wrote:

> Say i have 3 fields, named field1,field2 and field3
>
> I want to query all records that have "xxx" in field1 and filed3 should not
> be null
>
> I tried
> 1] q=field1:xxx&fq=?
> Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
> parse 'title:?': '*' or '?' not allowed as first character in WildcardQuery
>
> 2] q=filed1:xxx&fq=-x
> Got an error saying => org.apache.lucene.queryParser.ParseException: Cannot
> parse 'title:-smb': Encountered " "-" "- "" at line 1, column 6. Was
> expecting one of: "(" ... "*" ... ... ... ... ... "[" ... "{" ... ...
>
>
> Any suggestions?
>
> ----
> Thanks/Regards,
> Parvez
>