elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.75k stars 24.68k forks source link

suggest api enhancement #3199

Closed rkarakaya closed 11 years ago

rkarakaya commented 11 years ago

Hi,

I want to build a custom suggester and plug it into the existing suggest API. The problem I am facing is that the current suggester extension api dont let me to do my job.

I need to access:

Current API expose parameters only needed by built-in phrase and term suggester :-(

thanks. .

s1monw commented 11 years ago

At this point we already have an extension mechanism for this in place added in #3089 You have access to the searcher or rather to the index reader which is what you want at the end of the day. I am happy to expose the shard and the index as well, can you explain the usecase a bit more?

rkarakaya commented 11 years ago

Current Suggester.java execute API as fallows:

public Suggestion<? extends Entry<? extends Option>> execute(String name, T suggestion, IndexReader indexReader, CharsRef spare) throws IOException;

For example, at this point, I need searcher rather than reader.

My customer wanted me to build a suggester that supports:

As far as I understand, current phrase suggester does not support AND search. I mean, for instance it prompted "word1 word2" but no such document exists in my index that contains both words suggested. May be I am missing something:-)

Also, my customer wants to see more words other than what user typed and simple corrections. , So, I decided to build my own suggester using faceting on a field that contains shingles.

I can create totaly a new rest endpoint for my suggester but it would be awesome to plug it into the existing ES architecture.

s1monw commented 11 years ago

For example, at this point, I need searcher rather than reader.

you can simply call new IndexSearcher(reader); The seacher is a lightweight wrapper around the reader.

rkarakaya commented 11 years ago

Thank you Simon.. I didn't know that..

is it possible for you to extend SuggestionContext so that it contains index and shard info as well?

s1monw commented 11 years ago

is it possible for you to extend SuggestionContext so that it contains index and shard info as well?

yeah I think this makes sense! I will do that

rkarakaya commented 11 years ago

thank you very much..

s1monw commented 11 years ago

I have't ported this to 0.90 yet since I am waiting for #3089 to get ported... I will revisit this once we are done portin

s1monw commented 11 years ago

backported to 0.90