Query implementation

I am trying to translate my query language to ES. I have the following operators
AND, OR, NEAR, and NOT and I want to use any combination of them.

For example:
NOT A
NOT A*
(A OR B*) NEAR (C OR "D E")
NOT A OR NOT B
etc.

Using Span* I can implement AND OR and NEAR, but not NOT, however using bool I can implement
NOT

Any idea?

Thanks

The bool query can do both NOT (must_not clause), OR (should clause) and AND (must clause). For NEAR you can use span_near or match_phrase queries that you can then wrap into a bool query.

The bool query should be your main query as it allows you to add a clause (containing a term, range, wildcard, match_phrase and many other subqueries). The bool query is the glue that allows combining many queries.

Thanks,
I have problem with the proposed solution.

To translate the query (A OR B) NEAR (C OR D) - Span* can do the job, and I can not use bool for NEAR. However, to implement (NOT A) the best solution is to use bool. The main problem is that span_* does not accept bool queries.

Is there a way to implement (NOT term) with span_*?

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