I am trying to do a search using the Java API on a specific field
using the QueryStringQueryBuilder.field.
If I have 2 fields, one of type Integer, and one of type String, and
do a standard query across all fields for "bob", the search works as
expected.
If I tell the system to narrow the search to only the Integer field,
then search for "123", everything works as expected.
However, the search for "bob" results in a NumberFormatException[For
input string: "bob"]
It is apparently trying to convert "bob" to a number to do the search.
I cannot easily restrict what the user types in the search to know if
everything will convert. I would rather not have to parse the user
input looking for anything that will not match any field type that may
be selected. (We have dozens of different fields of different types)
Is this a known issue, or am I possibly doing something wrong? Why
does this work when I search across all fields?
Yea, the parser will try and use the provided value and convert it to
numeric if you query against it. You can do a simple check on the query
string, and if it is numeric, then query the integer field.
I am trying to do a search using the Java API on a specific field
using the QueryStringQueryBuilder.field.
If I have 2 fields, one of type Integer, and one of type String, and
do a standard query across all fields for "bob", the search works as
expected.
If I tell the system to narrow the search to only the Integer field,
then search for "123", everything works as expected.
However, the search for "bob" results in a NumberFormatException[For
input string: "bob"]
It is apparently trying to convert "bob" to a number to do the search.
I cannot easily restrict what the user types in the search to know if
everything will convert. I would rather not have to parse the user
input looking for anything that will not match any field type that may
be selected. (We have dozens of different fields of different types)
Is this a known issue, or am I possibly doing something wrong? Why
does this work when I search across all fields?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.