Problems with Query_String and different field types


(maho) #1

Hi,

I have an index with two fields:

  • name: description, type: string
  • name: price, type: double

If I send following query, I get an NumberFormatException[For input
string: "car"]

curl -XGET 'http://localhost:9200/sample/products/_search?pretty' -d
'{
"query" : {
"query_string" : {
"fields": ["description", "price"],
"query": "car"
}
}
}'

Of course, "car" cant be parsed to double, but can this be ignored?

Thanks.


Number_format_exception when querying field with long type using string
(maho) #2

Has no one an idea?

Or should i report an issue?

On 31 Mai, 13:49, maho mathias.hod...@gmail.com wrote:

Hi,

I have an index with two fields:

  • name: description, type: string
  • name: price, type: double

If I send following query, I get an NumberFormatException[For input
string: "car"]

curl -XGET 'http://localhost:9200/sample/products/_search?pretty'-d
'{
"query" : {
"query_string" : {
"fields": ["description", "price"],
"query": "car"
}
}

}'

Of course, "car" cant be parsed to double, but can this be ignored?

Thanks.


(Clinton Gormley) #3

curl -XGET 'http://localhost:9200/sample/products/_search?pretty'-d
'{
"query" : {
"query_string" : {
"fields": ["description", "price"],
"query": "car"
}

Why are you searching for 'car' against the field 'price'?

If you actually want to search for 'car' against the field 'description'
then use { "default_field": "description", "query": "car" }

Then if you want just the 'description' and 'price' fields to be
returned in the search results, you can use the "fields" clause above,
but at the same level as "query", not inside the query clause

clint


(maho) #4

Because I don't know what a user enters in the search field.

Maybe "car 2500" or "1300" or "car"

So what should I do if the user enters "car 2500"?
Of course I could parse the text and then building an appropriate
query. But that is too extensive, especially if you have more than two
fields.

In my opinion the would be best if ES ignoring unparsable text for the
particular field and not throwing an exception.

On 1 Jun., 11:19, Clinton Gormley clin...@iannounce.co.uk wrote:

curl -XGET 'http://localhost:9200/sample/products/_search?pretty'-d
'{
"query" : {
"query_string" : {
"fields": ["description", "price"],
"query": "car"
}

Why are you searching for 'car' against the field 'price'?

If you actually want to search for 'car' against the field 'description'
then use { "default_field": "description", "query": "car" }

Then if you want just the 'description' and 'price' fields to be
returned in the search results, you can use the "fields" clause above,
but at the same level as "query", not inside the query clause

clint


(system) #5