We're updating the issue view to help you get more done. 

Default value for "minimumShouldMatch" is different between Elasticsearch and Lucene

Description

Let say we have following entity

1 2 3 4 5 6 7 8 9 10 11 12 13 @Entity @Indexed public class YourAnnotatedEntity { @Id @DocumentId private Long id; @Field private String firstName; @Field private String lastName;

Query constructed in following way

1 2 3 4 5 6 Query query = qb.bool() .must(new TermQuery(new Term("id", "1"))) .filteredBy(qb.bool() .should(new TermQuery(new Term("firstName", "nonexisting"))) .must(new TermQuery(new Term("lastName", "jaric"))) .createQuery() ) .createQuery();

for given data set:

1 YourAnnotatedEntity yourEntity = new YourAnnotatedEntity( 1L, "goran", "jaric" );

returns different results (0 documents) if
hibernate.search.default.indexmanager=elasticsearch
and different result (1 document) if
hibernate.search.default.indexmanager=directory-based

If you use HSEARCH-3534_lucene.patch against https://github.com/hibernate/hibernate-test-case-templates/tree/master/search/hibernate-search-lucene, noneOfShouldMatchedWithinBooleanQueryInsideFilter_differentResults_directoryBasedVSElasticsearch test will pass, but
when you use HSEARCH-3534_elasticsearch.patch against https://github.com/hibernate/hibernate-test-case-templates/tree/master/search/hibernate-search-elasticsearch/hibernate-search-elasticsearch-5
the same test will fail.

Maybe using should and must in filters like siblings does not make much sense, because should (in directory-based) clause will be ignored, because document must fulfill must criterias and therefor should is ignored, and makes more sense in queries while scoring the search, however I ran into the issue while migrating huge project where such cases appear time to time, due to dynamic queries creation.

Environment

None

Status

Assignee

Fabio Massimo Ercoli

Reporter

Goran Jaric

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Fix versions

Affects versions

6.0.0.Alpha3
5.11.1.Final

Priority

Major