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

How to make a boosted phrase with FluentAPI? #386

Open
stas-lazarev-tga opened this issue Jun 14, 2024 · 2 comments
Open

How to make a boosted phrase with FluentAPI? #386

stas-lazarev-tga opened this issue Jun 14, 2024 · 2 comments

Comments

@stas-lazarev-tga
Copy link

stas-lazarev-tga commented Jun 14, 2024

Hello @Shazwazza

First of all thank you!
Great work on this package👍


As of v3.2.0,
It seems that the FluentAPI is missing an option to apply boosting on a phrase. Or at least I can't find how.

We can make a phrase with .Escape() like this:

externalIndex.Searcher.CreateQuery("content")
	.Field( "Title", "some phrase".Escape() );

And we can make a boosted term with .Boost() like this:

externalIndex.Searcher.CreateQuery("content")
	.Field( "Title", "potato".Boost(10) );

But how do I apply both?
How do I make it generate the following LuceneQuery using your FluentAPI methods:

Title:"some phrase"^10

FYI, In order to check the LuceneQuery string that is generated by FluentAPI methods I'm just calling a regular .ToString() on a query. Like this:

var queryString = externalIndex.Searcher.CreateQuery("content")
	.Field("Title", "some phrase".Escape())
	.ToString();
@Shazwazza
Copy link
Owner

Yes Examine API currently doesn't support chaining IExamineValue like .Escape().Boost(10)

A work around is to use a NativeQuery like

.NativeQuery("+phrase:"hello world"^10")

I'll look into adding this behavior but will most likely not be with chaining but the ability to pass in a boost to methods like Escape.

@Shazwazza
Copy link
Owner

This is a related topic: #329 (comment)

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

No branches or pull requests

2 participants