Problems with Query_String and different field types

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.

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.

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

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