Elasticsearch 5.4.0 - not like operation


(Vikentyi) #1

Hello. I am new to new version. I used 2.0.0 and it was possible to make a request 'NOT LIKE':

QueryBuilder qb = notQuery( wildcardQuery( "user", "k?mc*" ) );

But in new version I can't find how to make this request with NOT. Could you explain me how to build this request or it is impossible?

QueryBuilder qb = wildcardQuery("user", "k?mc*");


(David Pilato) #2

Use a boolQuery with a must_not clause.


(Vikentyi) #3

Thank you. I've done it but thought about any other solution.


(Vikentyi) #4

I have one question more: in old version I used SearchType.COUNT in Java API to count all matched documents to my query. In new version there is a documentation about COUNT API https://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html but how is it implemented in JAVA API?


(David Pilato) #5

Just run a normal search with setSize(0) and you will get a similar result.


(system) #6

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