Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted query_string gives NullPointerException with not_analyzed field (0.19.4) #2006

Closed
Frezzaldo opened this issue Jun 7, 2012 · 4 comments

Comments

@Frezzaldo
Copy link

After upgrading from Elasticsearch 0.19.2 to 0.19.4 this query failes:

{
"from" : 0,
"size" : 100000,
"query" : {
"query_string" : {
"query" : ""oai:bibsys.no:biblio:92116324x" "oai:bibsys.no:biblio:101924739" "oai:bibsys.no:biblio:921163258" "oai:bibsys.no:biblio:09372229x" "oai:bibsys.no:biblio:921163259" ",
"fields" : [ "otherid", "oaiid", "sesamid", "isbn", "urn" ]
}
},
"explain" : false,
"sort" : [ {
"_id" : {
"order" : "asc"
}
} ]
}

What we want, is to use the query_string to get the exact match.

Mappings:

"otherid":{"type":"string"},
"isbn":{"type":"string", "analyzer":"isbn"},
"urn":{"type":"string", "index":"not_analyzed", "boost":2.0},
"sesamid":{"type":"string", "index":"not_analyzed"},
"oaiid":{"type":"string", "index":"not_analyzed", "boost":2.0},

Elasticsearch log:

Parse Failure [Failed to parse source [{"from":0,"size":100000,"query":{"query_string":{"query":""oai:bibsys.no:biblio:92116324x" "oai:bibsys.no:biblio:101924739" "oai:bibsys.no:biblio:921163258" "oai:bibsys.no:biblio:09372229x" "oai:bibsys.no:biblio:921163259" ","fields":["otherid","oaiid","sesamid","isbn","urn"]}},"explain":false,"sort":[{"_id":{"order":"asc"}}]}]]
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:557)
at org.elasticsearch.search.SearchService.createContext(SearchService.java:469)
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:228)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:497)
at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:486)
at org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:373)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
at org.elasticsearch.index.mapper.MapperService$SmartIndexNameSearchQuoteAnalyzer.reusableTokenStream(MapperService.java:976)
at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:574)
at org.apache.lucene.queryParser.MapperQueryParser.getFieldQuerySingle(MapperQueryParser.java:238)
at org.apache.lucene.queryParser.MapperQueryParser.getFieldQuery(MapperQueryParser.java:186)
at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:752)
at org.apache.lucene.queryParser.MapperQueryParser.getFieldQuery(MapperQueryParser.java:257)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1580)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1317)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1245)
at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1234)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
at org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:206)
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:187)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:249)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:229)
at org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)
at org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)

As you can see we get a NullPointerException in MapperService(976) which is new code in 0.19.4. It looks like it has something to do with the searchQuoteAnalyzer().

If we remove the quotes(") around each query string, this query runs fine, but we get more hits then we want to. I guess, this is because "otherid" is not set to "not_analyzed".

Another query that also generate the same NPE:
{
"size": 1000,
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"field": {
"title": ""Flammekaster""
}
},
{
"field": {
"creator": ""Dalby, Gene""
}
},
{
"field": {
"year": ""1981""
}
},
{
"field": {
"mediatype": ""Bøker""
}
}
]
}
},
{
"field": {
"status": "PROCESSED INDEXED FIELDS_EXTRACTED"
}
}
]
}
},
"fields": [
"title",
"creator",
"isbn",
"year",
"mediatype"
],
"sort": [
{
"dedup_primarySourceScore": {
"order": "desc"
}
},
{
"dedup_modsSize": {
"order": "desc"
}
},
{
"oaiid": {
"order": "asc"
}
}
]
}

@kimchy
Copy link
Member

kimchy commented Jun 7, 2012

I think I fixed it in a recent commit to 0.19 branch, si there a chance for a full recreation to verify it?

@Frezzaldo
Copy link
Author

I ran our software tests with the latest 0.19 (0.19.5-SNAPSHOT). I also tried the master (0.20.0.Beta1-SNAPSHOT).

Exception message:
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], total failure; shardFailures: from[0],size[100000]: Parse Failure [Failed to parse source [:)
�⃦²om�size$�5��query⋱µery_string₠¢oai:bibsys.no:biblio:92116324x" "oai:bibsys.no:biblio:101924739" "oai:bibsys.no:biblio:921163258" "oai:bibsys.no:biblio:09372229x" "oai:bibsys.no:biblio:921163259" 䅦©elds毴heridDoaiidFsesamidCisbnBurnỻ�explain"�sortຂ�idℯ²derBasc㻹»]]]; nested: }

The query that failed:

{
"from" : 0,
"size" : 100000,
"query" : {
"query_string" : {
"query" : ""oai:bibsys.no:biblio:92116324x" "oai:bibsys.no:biblio:101924739" "oai:bibsys.no:biblio:921163258" "oai:bibsys.no:biblio:09372229x" "oai:bibsys.no:biblio:921163259" ",
"fields" : [ "otherid", "oaiid", "sesamid", "isbn", "urn" ]
}
},
"explain" : false,
"sort" : [ {
"_id" : {
"order" : "asc"
}
} ]
}

@kimchy
Copy link
Member

kimchy commented Jun 8, 2012

can you provide a curl based recreation? Including setting up the index, indexing some sample data, and search that shows the failure?

@Frezzaldo
Copy link
Author

I'm going on a Holiday now, but I have informed my colleagues about this.

@kimchy kimchy closed this as completed in e53db1a Jun 10, 2012
hibnico pushed a commit to hibnico/elasticsearch that referenced this issue Jun 25, 2012
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants