0

I just want to get all result from a simple Pseudo-SQL query like that:

[...] WHERE 'idGroups' = '7078' AND ('titre' LIKE '%fuite%' OR 'tag' LIKE '%fuite%' OR 'message' LIKE '%fuite%')

In done that:

        BoolQueryBuilder qb = QueryBuilders
                .boolQuery()
                .must(QueryBuilders.termQuery("idGroups", 7078))
                .should(QueryBuilders.termQuery("titre", "fuite"))
                .should(QueryBuilders.termQuery("tag", "fuite"))
                .should(QueryBuilders.termQuery("message", "fuite"));

Obviously, that is not returning me desired result .. What's wrong?

Thank you :)

1 Answer 1

1

Can you try this:

QueryBuilders
            .boolQuery()
            .must(QueryBuilders.termQuery("idGroups", 7078))
            .should(QueryBuilders.wildcardQuery("titre", "*fuite*"))
            .should(QueryBuilders.wildcardQuery("tag", "*fuite*"))
            .should(QueryBuilders.wildcardQuery("message", "*fuite*")).minimumShouldMatch(1);
Sign up to request clarification or add additional context in comments.

10 Comments

I tried it, but this isn't working better. For example, if I do that: QueryBuilders .boolQuery() .must(QueryBuilders.termQuery("idGroups", 7078)) .should(QueryBuilders.wildcardQuery("titre", "*fuite*")) I have some result with "TEST EVENEMENT - MANDAT" or "Test SDB" as "titre" ..
This is the same result .. Not really more efficient
Do you use some plugin like sense or something where you write Elasticsearch Query DSL. Then Try this Query: {"query":{"bool":{"must":[{"term":{"idGroups":{"value":7078}}},{"query_string":{"fields":["titre","tag","message"],"query":"*fuite*"}}]}}}
And Please share mapping of your index. GET /index/type/_mapping
So, my war deployement failed and your update hasn't been used. Now, with your update with "minimumShouldMatch", it works better! But, If I execute the request with "fuite", I have a result like "fuite eau" as "titre". When I execute the request with "fuite eau", I have 0 results ..
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.