2

I am developing an autocomplete feature in which i intend to show query suggestions something like this:

students who live in {City_name} [ City_name could contain values from list of cities ]

example_type 1 :

students who live in New...

[ following query suggestions should pop-up ] :

students who live in New york
students who live in New Jersey

(Looking up different entities [here cities, sports (eg: "students who play basketball" etc...]. )

example_type 2:

students who live in New york and play ba...

[ following query suggestions should pop-up ] :

students who live in New York and play basketball
students who live in New York and play baseball
etc..

I have tried building basic autocomplete on entities index using ElasticSearch, which is gisted here. (In my case, the child/entities index is dumped using a river-plugin.) I have naively checked on Nested Types and Parent / Child relationship but was not able to exactly figure out whether its the right fit for my requirement.

I am not sure on how to index these (parent) phrases alongwith child index to enable autocomplete search and generate possible suggest trees by querying/searching a single index.

It would be great if i can get some help to solve this kind of problem. Thanks in advance!

4

1 回答 1

0

我会索引短语,例如:

live in New york
live in New Jersey
play basketball
play baseball

然后在客户端做一些工作来确定你已经在查询中开始了一个新的部分,然后只将新部分中的字母发送给 ES 以进行预先输入完成。

这将在前端进行一些工作,但我可以看到工作。另一种选择是索引查询短语的所有可能变体以进行预输入,但我高度怀疑这是可行的。

于 2013-08-05T09:54:46.560 回答