[英]How to do full text search matching on partial Elasticsearch queries
I use Elasticsearch with Laravel, I implement everything and it works with simple match queries like in the code above. 我将Elasticsearch与Laravel结合使用,实现了所有功能,并且可以与简单的匹配查询一起使用,如上面的代码中所示。
'body' => [
"query" => [
"bool" => [
"should" => [
["regexp" => [
"tags" => [
"value" => ".{2,8}" . $query . ".*",
]
],
],
["wildcard" => [
"tags" => [
"value" => "*" . $query . "*",
"boost" => 1.0,
"rewrite" => "constant_score"
]
]
]
]],
], "highlight" => [
"fields" => [
"tags" => ["type" => "plain"]
]
]
]
I receive good results like on query "java" I receive both "javascript" & "nativjavascript" But the problem is with receiving results in phrases. 我收到了类似查询“ java”的良好结果,同时收到了“ javascript”和“ nativjavascript”,但是问题在于接收短语结果。
I want to type in query "java react" and want to receive this results: "java","javascript","javascript reactjs", "reactjs","react", "nativjavascript". 我想输入查询“ java react”,并希望接收以下结果:“ java”,“ javascript”,“ javascript reactjs”,“ reactjs”,“ react”,“ nativjavascript”。
I am not familiar with Laravel, hence can't provide you the exact syntax but can tell the approach and how I solved this use-case in my application. 我对Laravel不熟悉,因此无法为您提供确切的语法,但可以告诉您该方法以及我如何在应用程序中解决此用例。
space
, in your case java react
, should be split into 2 search term java
and react
. space
拆分搜索词,在您使用java react
的情况下,应将其拆分为2个搜索词java
and react
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.