Combinig queries dilemma

I am quite new to ES and have used some example code provided by someone else to get me to where I am at the moment.

I'm using the Elastica PHP wrapper to produce the queries, just FYI although it has no bearing on what I'm asking.

I have used the Querystring query to perform my search so I can use the AND and OR keywords. The client is requesting fuzzy based searching while maintaining the querystring style, and I'm at a complete loss as to how to do this with ES.

My current query object looks like this:

"query":{ "query_string":{ "query":"chicken OR fish", "default_operator":"AND", "fields":["*.custom_fulltext"] } }

Which searches a custom index in a lot of multi_fields throughout our multiple mappings.

I've found examples on how to fuzzy search multiple fields, where I would have to reproduce the query multiple times for each field. This I can't do as we have over 10 mappings and many fields in each one, and the cost of query overhead to do this is too much.

What I need to know is how to do both styles of query at the same time and produce results as would be generated from the example, but using fuzzy logic on every keyword in case someone misspels a word.

Any help anyone can give me would be greatly appreciated as I've been stuck for days staring at ES docs with no clue.

Thanks in advance.

1 Like