Using Cutoff Frequency in a Multi-Match Query Causes Irrelevant Results

Hey,

I read that Common Terms technique is supposed to enhance search results, however, when I added it to my code, the opposite happened.

Here's my code:

     var response = elasticClient.Search<Document>(s => s
                .From(offset)
                .Size(size)
                .Index(name)
                .Query(q => q
                    .FunctionScore(fs => fs.Query(qy => qy
                    .Bool(b => b
                        .Must(m => m
                            .Term(tm => tm.Field(fd => fd.Client)
                                .Value(client)
                            )
                        )
                        .MustNot(mn => mn
                            .Terms(t => t.Field(f => f.Client).Terms(other))
                            )
                        .Should(m => m
                            .QueryString(ss => ss.Query("\"" + query.Data + "\"").QuoteFieldSuffix(".exact").Fields(fd => fd
                                        .Field(f => f.Title, exactMatchBoost?.TitleBoost)
                                        .Field(f => f.Summary, exactMatchBoost?.SummaryBoost)
                                        .Field(f => f.Content, exactMatchBoost?.ContentBoost)
                                        .Field(f => f.Tags, exactMatchBoost?.TagBoost)
                                        .Field(f => f.Meta, exactMatchBoost?.MetaBoost)
                                        .Field(f => f.Relations, exactMatchBoost?.RelationsBoost)
                                        .Field(f => f.Type, exactMatchBoost?.TypeBoost)
                                        .Field(f => f.MainTerms, exactMatchBoost?.MainTermsBoost)
                                        .Field(f => f.Terms, exactMatchBoost?.TermsBoost)
                                        .Field(f => f.RelationsSummary, exactMatchBoost?.RelationsSummaryBoost)
                                        ))
                             , m => m
                             .MultiMatch(mm => mm
                                     .Fields(fd => fd
                                         .Field(f => f.Title, analyzedMatchBoost?.TitleBoost)
                                         .Field(f => f.Summary, analyzedMatchBoost?.SummaryBoost)
                                         .Field(f => f.Content, analyzedMatchBoost?.ContentBoost)
                                         .Field(f => f.Tags, analyzedMatchBoost?.TagsBoost)
                                         .Field(f => f.Type, analyzedMatchBoost?.TypeBoost)
                                         .Field(f => f.Terms, analyzedMatchBoost?.TermsBoost)
                                         .Field(f => f.MainTerms, analyzedMatchBoost?.MainTermsBoost)
                                         .Field(f => f.RelationsSummary, analyzedMatchBoost?.RelationsSummaryBoost)
                                         .Field(f => f.Meta, analyzedMatchBoost?.MetaBoost)
                                         .Field(f => f.Relations, analyzedMatchBoost?.RelationsBoost)
                                     )
                                     .Type(TextQueryType.BestFields)
                                     .Operator(Operator.And)
                                     .Query(query.Data)
                                     .TieBreaker(analyzedMatchBoost?.TieBreaker)
                                     .CutoffFrequency(0.001)
                                     )
                                    , m => m
                                    .MultiMatch(mm => mm
                                        .Fields(fd => fd
                                        .Field(f => f.Type)
                                        .Field(f => f.MainTerms)
                                        )
                                        .Type(TextQueryType.CrossFields)
                                        .Operator(Operator.And)
                                        .Query(query.Data)
                                        .Boost(settings?.MainTermsAndTypeBoost)
                                        )
                                    , m => m
                                    .MultiMatch(mm => mm
                                      .Fields(fd => fd
                                          .Field(f => f.MainTerms)
                                          .Field(f => f.Tags)
                                          )
                                          .Type(TextQueryType.CrossFields)
                                          .Operator(Operator.And)
                                          .Query(query.Data)
                                          .Boost(settings?.MainTermsAndTagsBoost))
                                    )
                                    .Filter(fr => fr
                                    .MultiMatch(mm => mm
                                                  .Fields(fd => fd
                                                      .Field(f => f.Title)
                                                      .Field(f => f.Summary)
                                                      .Field(f => f.Content)
                                                      .Field(f => f.Tags)
                                                      .Field(f => f.Meta)
                                                      .Field(f => f.Relations)
                                                      .Field(f => f.Type)
                                                      .Field(f => f.MainTerms)
                                                      .Field(f => f.Terms)
                                                      .Field(f => f.RelationsSummary)
                                                  )
                                                  .Type(TextQueryType.CrossFields)
                                                  .Operator(Operator.Or)
                                                  .Query(query.Data)
                                                  .MinimumShouldMatch(settings.MinShouldMatch + "%")
                                                  )
                                    )
                    )
                )
            )
            )
            );

can you please check if I'm doing anything wrong?

Is the cut-off frequency only used in case of being certain that the query is made up of only stop words?

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