Needs advice on auto-keyword-correction mode custom query

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Needs advice on auto-keyword-correction mode custom query

小鱼儿-2
Hi everybody,

I want to implement an auto-keyword-correction mode custom query: suppose a
scenario where user inputs a keyword query A, but due to typo or other
reasons, A should be B, A is not a valid term in lucene's index which B is.
(I'm not considering NLP in high-dimensional semantice space which is out
of scope here)

I could use 2 queries to do this, but it's too costly. What i need is a
"early-termination" mode:
 (1) keyword A will hit a non-empty DocIDSet so will not query B; Or
 (2) keyword A's DocIDSet will be empty and B's will then match

That is "A OR B" likewise in C/C++ language. But here i notice Lucene's
BooleanQuery's SHOULD relationship is not the solving way. Perhaps i need
to implement another custom query class?

btw, How can Lucene's Query API become high-order composable? Lucene's
"LeafContext" concept is really very confusing me...
Reply | Threaded
Open this post in threaded view
|

Re: Needs advice on auto-keyword-correction mode custom query

Mikhail Khludnev-2
I think you need to search A for single doc with early termination. And
then search for either A or B.
The closest conditional logic query is WAND, but it doesn't do what's asked
here.
btw, IndexSearcher combines Indices, and Queries.

On Mon, Jan 6, 2020 at 7:33 AM 小鱼儿 <[hidden email]> wrote:

> Hi everybody,
>
> I want to implement an auto-keyword-correction mode custom query: suppose a
> scenario where user inputs a keyword query A, but due to typo or other
> reasons, A should be B, A is not a valid term in lucene's index which B is.
> (I'm not considering NLP in high-dimensional semantice space which is out
> of scope here)
>
> I could use 2 queries to do this, but it's too costly. What i need is a
> "early-termination" mode:
>  (1) keyword A will hit a non-empty DocIDSet so will not query B; Or
>  (2) keyword A's DocIDSet will be empty and B's will then match
>
> That is "A OR B" likewise in C/C++ language. But here i notice Lucene's
> BooleanQuery's SHOULD relationship is not the solving way. Perhaps i need
> to implement another custom query class?
>
> btw, How can Lucene's Query API become high-order composable? Lucene's
> "LeafContext" concept is really very confusing me...
>


--
Sincerely yours
Mikhail Khludnev