Q:

How to filter out elastic searches for invalid inputs

We are currently trying to process user input and checking if user has entered a food item using elastic search.
With elastic search we are able to get results for wide range of terms: Garlic , Garlic Extract etc...
How should we handle use cases E.g. Blueberry Dish-washing soap  Or Apple based liquid soap . How do we omit these searches ? 
As I search Blueberry Dish-washing soap I still get search results related to Blueberry 

A:

Your objective requires that you perform part of speech tagging on your query, and then use those tags to identify nouns.
You would then need to compare the extracted nouns to a pre-curated list of food strings and, after identifying those that are not food, remove the clauses of which those nouns are the subject and /or the phrases of which they are the object.
This functionality is not built into elasticsearch. Depending on what language you are processing your queries with, there are various libraries for part of speech tagging and string manipulation.
Updated answer:
Just read through this and realized this answer isn't very good. The best way to solve this problem is with document/phrase vectorization. Vectorized properly, you should be able to encode the noun phrases 'Blueberry' and 'Blueberry dishwashing soap' as very different vectors, and then you can take all sorts of approaches as far as inferring classifications from those vectors.

