我对Search腿有意见。当我像这样发送查询时
Position.search(
query.downcase,
fields: [:name],
include: [:brand],
where: {},
per_page: 40,
page: 1,
order: [:name]
)Searchkick请求有许多类似的查询
http://127.0.0.1:9200/positions_development/_search?pretty -d '{"query":{"dis_max":{"queries":[{"match":{"name.analyzed":{"query":"fly","boost":10,"operator":"and","analyzer":"searchkick_search"}}},{"match":{"name.analyzed":{"query":"fly","boost":10,"operator":"and","analyzer":"searchkick_search2"}}},{"match":{"name.analyzed":{"query":"fly","boost":1,"operator":"and","analyzer":"searchkick_search","fuzziness":1,"prefix_length":0,"max_expansions":3,"fuzzy_transpositions":true}}},{"match":{"name.analyzed":{"query":"fly","boost":1,"operator":"and","analyzer":"searchkick_search2","fuzziness":1,"prefix_length":0,"max_expansions":3,"fuzzy_transpositions":true}}}]}},"size":40,"from":0,"sort":{"have_price":"desc"},"facets":{},"timeout":"11s","fields":[]}'但是当我将查询更改为
Position.search(
query.downcase,
fields: [:name],
include: [:brand],
where: {},
per_page: 40,
page: 1,
order: [:name],
match: :word_start
)只使用两个查询发送此请求
curl http://127.0.0.1:9200/positions_development/_search?pretty -d '{"query":{"dis_max":{"queries":[{"match":{"name.word_start":{"query":"fly","boost":10,"operator":"and","analyzer":"searchkick_word_search"}}},{"match":{"name.word_start":{"query":"fly","boost":1,"operator":"and","analyzer":"searchkick_word_search","fuzziness":1,"prefix_length":0,"max_expansions":3,"fuzzy_transpositions":true}}}]}},"size":40,"from":0,"sort":{"have_price":"desc"},"facets":{},"timeout":"11s","fields":[]}'“搜索踢”,“1.3.5” “‘rails”,“4.1.5” elasticsearch 1.7.4
我怎么能解决这个问题而只发送一个查询呢?
发布于 2018-07-30 19:16:09
需要添加misspellings: false来搜索像这样的方法
Position.search(
query.downcase,
fields: [:name],
include: [:brand],
where: {},
per_page: 40,
page: 1,
order: [:name],
misspellings: false,
match: :word_start
)https://stackoverflow.com/questions/51585477
复制相似问题