By default the standard query parser has no idea about field types (and it cannot because it does not know the schema of your index). If you want to allow searching in non-text fields (TextField, all other - also normal StringField breaks easy), you need to customize it.

There are 2 query parsers that I would call "standard":

 * For the default / classic QueryParser the QueryParser#newXYQuery
   methods need to be adapted (by subclassing) to generate a query
   based on the text input. This is how Solr/Elasticsearch adapt their
 * For the flexible query parser (I think you mean that one with
   StandardQueryParser), there is an option to use PointsConfig
   instances and set a "per field" mapping how to parse points. Use
   StandardQueryParser#setPointsConfigMap‚Äč() for that. Unfortunately
   Javadocs is missing....

This is what Solr/Elasticsearch/Opensearch do.


Am 14.11.2023 um 03:01 schrieb Tony Schwartz:

I'm banging my head at this point, hoping someone can help me.

I can't get StandardQueryParser to work on numeric fields.  Luke v9.8.0
finds the records for me.  Example search query string in Luke that works:

Here is my code:

Query initQuery() {

StandardQueryParser p = new StandardQueryParser( analyzer );

p.setDefaultOperator( StandardQueryConfigHandler.Operator.AND );

String queryString = "eventIdNum:3001";

return p.parse( queryString, "any" );


here is how the field was added to the index:

d.add( new IntField( "eventIdNum", 3001, Field.Store.NO ) );

I've tried various analyzers.  Example:  new StandardAnalyzer(
CharArraySet.EMPTY_SET );

I'm sure there is something I'm missing here, but I can't seem to track down
what I'm missing.  The analyzer is the exact same analyzer I'm using during
indexing.  It's a PerFieldAnalyzerWrapper.  The specific analyzer for the
numeric fields is the one I mentioned above (StandardAnalyzer).

The query used is:

indexSearcher.search( query, 10 );

Thank you,

Tony Schwartz

Uwe Schindler
Achterdiek 19, D-28357 Bremen

Reply via email to