Ignoring the search field if left empty

Hi everyone,

I am new to Elasticsearch and for the past few weeks, I have been wrangling with Elasticsearch to create a search functionality for the website I am creating.

At the moment, I am working on an "Advanced Search" functionality where users can search with multiple criteria. But I am not too sure on how to deal with empty fields; for example, say a user specifies field 1 and field 3 but not field 2 then I would like the search results to return results that match field 1 AND field 3 but ignore field 2. I have tried using an all indicator (i.e. * in kibana) but it doesn't seem to work on the query.

Could anyone provide some insights on how I can go about doing this?

Thank you,
Thomas

Here is how I built an advanced search like feature in Java:

I hope this helps.

Hey David,

Thanks for the reply.

Is there any equivalent to boolQueryBuilder or QueryBuilders in PHP?

Best,
Thomas

This ?

https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_search_operations.html#_bool_queries

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.