Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiMatch with empty string on function score #477

Closed
andreabalducci opened this issue Feb 20, 2014 · 5 comments
Closed

MultiMatch with empty string on function score #477

andreabalducci opened this issue Feb 20, 2014 · 5 comments

Comments

@andreabalducci
Copy link
Contributor

I'm upgrading from my old fork to the master and I've found that the MultiMatch with empty query produces

query: {}

instead of

query: { match_all : {} }

Is that right and we have to check the query string to change our QueryDescriptor or the multimatch should fallback on match_all ?

var s = new SearchDescriptor<ElasticsearchProject>().From(0).Size(10)
                .Query(q => q
                    .FunctionScore(fs => fs
                        .Query(qq => qq.MultiMatch(mm => mm.OnFields(f=>f.Country, f=>f.FloatValue).Query("")))
                        .Functions(
                            f => f.Gauss(x => x.StartedOn, d => d.Scale("42w")),
                            f => f.Linear(x => x.FloatValue, d => d.Scale("0.3")),
                            f => f.Exp(x => x.DoubleValue, d => d.Scale("0.5")),
                            f => f.BoostFactor(2)
                        )
                        .ScoreMode(FunctionScoreMode.sum)
                    )
                ).Fields(x => x.Content);
@Mpdreamz
Copy link
Member

The default for conditionless queries is to fallback to an empty query (effectivily a match_all)

The master has a construct that allows you to control what to fallback to:

qq.Conditionless(c=>c
    .Query(cq=>cq.MultiMatch(mm => mm.OnFields(f=>f.Country, f=>f.FloatValue).Query("")))
    .Fallback(fq=>fq.MatchAll())
)

@andreabalducci
Copy link
Contributor Author

An empty query object give me QueryParsingException (query malformed) on ES (still on ES 0.90.8).

Thanks!

@Mpdreamz Mpdreamz reopened this Feb 20, 2014
@Mpdreamz
Copy link
Member

Closed too quickly perhaps

Here's a ponder:

If the query inside functionscore is conditionless should the functionscore itself become conditionless or do a match_all?

Im inclined to say the first because thats how all the other conditionless queries bubble up. Love your thoughts on this @andreabalducci

PS: I see you use .Fields(). Elasticsearch changed the return type for fields to always return an array.

If you want to return a subset of your document while still mapping the result into result.Documents use this instead:

.Source(s=>s.Include(p=>p.Content))

@andreabalducci
Copy link
Contributor Author

I'm switching from my function score fork, the old behaviour was match_all and I think it is was correct one.

For a LOB make sense, if you are Google Search maybe not.. I think is a business driven choice.

@andreabalducci
Copy link
Contributor Author

Thanks for the .Fields() hint, that piece of code is from my old unit test on function score (still in the master).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants