lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: New equivalent to QueryParsing.parseQuery()?
Date Thu, 15 May 2014 19:54:14 GMT

: me incorporate these config files as before. I'm (naively?) trying the
: following:
:         final StandardQueryParser parser = new StandardQueryParser();
:         final Query luceneQuery = parser.parse(query, "text");
:         luceneIndex.getIndexSearcher().search(luceneQuery, collector);
: However, the behavior of the StandardQueryParser seems to be different
: enough to make some previously good queries fail, and I've not found a new

I don't think there's anything particular about StandardQueryParser that 
has changed that would make your queries fail -- however what you have 
there doens't refer to your schema at all, so that would obviously result 
in differences.

The main reason QueryParser.parseQuery went away is that it wasn't able to 
track any context of the request, so query time options for things like 
the default field were a pain to deal with -- no to mention doing parser 

The closest corelary to what you were doing before is construct a 
LocalSolrQueryRequest and then pass that to QParser.getParser().

But if you are really just completley bypassing Solr, and constructing 
IndexSchema and SolrIndexConfig objects yourself -- you probably don't 
have a SolrCore object, which means that approach is probablematic.

Altenatively, you could try passing schema.getQueryAnalyzer() to your 
StandardQueryParser constructor -- that will give you all of the 
appropriate analyzers, but it won't help with some of the other FieldType 
specific features (like knowing when to build NumericRangeQueries for trie 
fields, when docValues are used, etc...)

Somewhere in between those two suggestions would be implementing 
SolrQueryRequest yourself with a a new mock object that gives access to 
the schema but just throws UnsupportedOperationExceptio for anything 
related to the SolrCore -- and then use that to directly construct a 
"LuceneQParser" instance and an org.apache.solr.parser.QueryParser 
instance.  (once you are that deep into the parsing logic, the only parsts 
of the SolrQueryRequest that hsould be consulted are the schema)


View raw message