Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-3534

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

    Details

      Description

      Let say we have following entity

      @Entity
      @Indexed
      public class YourAnnotatedEntity {
      
      	@Id
      	@DocumentId
      	private Long id;
      
      	@Field
      	private String firstName;
      
      	@Field
      	private String lastName;
      

      Query constructed in following way

      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:

      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.

        Attachments

          Activity

            People

            • Assignee:
              fercoli Fabio Massimo Ercoli
              Reporter:
              goran Goran Jaric
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: