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
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.
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
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.