Problem parsing queries with forward slashes and multiple fields

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem parsing queries with forward slashes and multiple fields

Yury Kats
I'm running into a problem with queries that contain forward slashes and more than one field.

For example, these queries work fine:
fieldName:/a
fieldName:/*

But if I have two fields with similar syntax in the same query, it fails.

For simplicity, I'm using the same field twice:

fieldName:/a fieldName:/a

results in: "no field name specified in query and no defaultSearchField defined in schema.xml"

SEVERE: org.apache.solr.common.SolrException: no field name specified in query and no defaultSearchField defined in schema.xml
        at org.apache.solr.search.SolrQueryParser.checkNullField(SolrQueryParser.java:106)
        at org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParser.java:124)
        at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1058)
        at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:358)
        at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:257)
        at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:212)
        at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:170)
        at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:118)
        at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:74)
        at org.apache.solr.search.QParser.getQuery(QParser.java:143)


fieldName:/* fieldName:/*

results in: null

java.lang.NullPointerException
        at org.apache.solr.schema.IndexSchema$DynamicReplacement.matches(IndexSchema.java:747)
        at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1026)
        at org.apache.solr.schema.IndexSchema.getFieldType(IndexSchema.java:980)
        at org.apache.solr.search.SolrQueryParser.getWildcardQuery(SolrQueryParser.java:172)
        at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1039)
        at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:358)
        at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:257)
        at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:212)
        at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:170)
        at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:118)
        at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:74)
        at org.apache.solr.search.QParser.getQuery(QParser.java:143)


Any ideas as to what may be wrong and how can I make these work?

I'm on a 4.0 snapshot from Nov 29, 2011.
Em
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Em
Yury,

are you sure your request has a proper url-encoding?

Kind regards,
Em

Am 22.02.2012 18:25, schrieb Yury Kats:

> I'm running into a problem with queries that contain forward slashes and more than one field.
>
> For example, these queries work fine:
> fieldName:/a
> fieldName:/*
>
> But if I have two fields with similar syntax in the same query, it fails.
>
> For simplicity, I'm using the same field twice:
>
> fieldName:/a fieldName:/a
>
> results in: "no field name specified in query and no defaultSearchField defined in schema.xml"
>
> SEVERE: org.apache.solr.common.SolrException: no field name specified in query and no defaultSearchField defined in schema.xml
> at org.apache.solr.search.SolrQueryParser.checkNullField(SolrQueryParser.java:106)
> at org.apache.solr.search.SolrQueryParser.getFieldQuery(SolrQueryParser.java:124)
> at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1058)
> at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:358)
> at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:257)
> at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:212)
> at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:170)
> at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:118)
> at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:74)
> at org.apache.solr.search.QParser.getQuery(QParser.java:143)
>
>
> fieldName:/* fieldName:/*
>
> results in: null
>
> java.lang.NullPointerException
> at org.apache.solr.schema.IndexSchema$DynamicReplacement.matches(IndexSchema.java:747)
> at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1026)
> at org.apache.solr.schema.IndexSchema.getFieldType(IndexSchema.java:980)
> at org.apache.solr.search.SolrQueryParser.getWildcardQuery(SolrQueryParser.java:172)
> at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:1039)
> at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:358)
> at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:257)
> at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:212)
> at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:170)
> at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:118)
> at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:74)
> at org.apache.solr.search.QParser.getQuery(QParser.java:143)
>
>
> Any ideas as to what may be wrong and how can I make these work?
>
> I'm on a 4.0 snapshot from Nov 29, 2011.
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yury Kats
In reply to this post by Yury Kats
On 2/22/2012 12:25 PM, Yury Kats wrote:

> I'm running into a problem with queries that contain forward slashes and more than one field.
>
> For example, these queries work fine:
> fieldName:/a
> fieldName:/*
>
> But if I have two fields with similar syntax in the same query, it fails.
>
> For simplicity, I'm using the same field twice:
>
> fieldName:/a fieldName:/a

Looks like escaping forward slashes makes the query work, eg
  fieldName:\/a fieldName:\/a

This is a bit puzzling as the forward slash is not part of the query language, is it?
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yury Kats
In reply to this post by Em
On 2/22/2012 1:05 PM, Em wrote:
> Yury,
>
> are you sure your request has a proper url-encoding?

Yes
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yonik Seeley-2-2
In reply to this post by Yury Kats
2012/2/22 Yury Kats <[hidden email]>:

> On 2/22/2012 12:25 PM, Yury Kats wrote:
>> I'm running into a problem with queries that contain forward slashes and more than one field.
>>
>> For example, these queries work fine:
>> fieldName:/a
>> fieldName:/*
>>
>> But if I have two fields with similar syntax in the same query, it fails.
>>
>> For simplicity, I'm using the same field twice:
>>
>> fieldName:/a fieldName:/a
>
> Looks like escaping forward slashes makes the query work, eg
>  fieldName:\/a fieldName:\/a
>
> This is a bit puzzling as the forward slash is not part of the query language, is it?

Regex queries were added that use forward slashes:

https://issues.apache.org/jira/browse/LUCENE-2604

-Yonik
lucidimagination.com
Em
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Em
In reply to this post by Yury Kats
That's strange.

Could you provide a sample dataset?

I'd like to try it out.

Kind regards,
Em

Am 22.02.2012 19:17, schrieb Yury Kats:
> On 2/22/2012 1:05 PM, Em wrote:
>> Yury,
>>
>> are you sure your request has a proper url-encoding?
>
> Yes
>
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yury Kats
On 2/22/2012 1:25 PM, Em wrote:
> That's strange.
>
> Could you provide a sample dataset?

Data set does not matter. The query fails to parse, long before it gets to the data.
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yury Kats
In reply to this post by Yonik Seeley-2-2
On 2/22/2012 1:24 PM, Yonik Seeley wrote:

>> This is a bit puzzling as the forward slash is not part of the query language, is it?
>
> Regex queries were added that use forward slashes:
>
> https://issues.apache.org/jira/browse/LUCENE-2604

Oh, so / is a special character now? I don't think it is mentioned as such on any of the wiki pages,
or in org.apache.solr.client.solrj.util.ClientUtils
Reply | Threaded
Open this post in threaded view
|

Re: Problem parsing queries with forward slashes and multiple fields

Yury Kats
In reply to this post by Yonik Seeley-2-2
On 2/22/2012 1:24 PM, Yonik Seeley wrote:
>> Looks like escaping forward slashes makes the query work, eg
>>  fieldName:\/a fieldName:\/a
>>
>> This is a bit puzzling as the forward slash is not part of the query language, is it?
>
> Regex queries were added that use forward slashes:
>
> https://issues.apache.org/jira/browse/LUCENE-2604

Looks like regex matching happens across multiple fields though. Feels like a bug to me?