如何写一个elasticsearchservice.search(Closure query, params, filter)?
How to write a elasticsearchservice.search(Closure query, params, filter)?
我正在尝试为我的 grails 应用程序实施弹性搜索。我使用的是 grails 3.3.6 版本,gradle wrapper 3.1,grails elasticsearch 插件是 2.4.0,elastic search 版本是 5.4.1。
我正在努力在 elasticsearchservice class 中传递搜索方法的参数。
"elasticsearchservice.search(闭包查询、参数、过滤器)"
我像这样传递参数并在
上出错
match
elasticSearchService.search({match(fields: ["title", "description"],
query: q,fuzziness:'4',fuzzy_prefix_length:1)}, null,[indices: Book, types: Book, score: true])
实际上,我在这里尝试使用具有模糊性的匹配,我尝试使用 kibana 和 postman 来使用 elasticsearch _search。它在那里工作。
POST /books/code/_search
{
"query": {
"match": {
"author": {
"query": "keeen",
"fuzziness": 4,
"prefix_length": 1
}
}
}
}
我想在控制台中为我的应用程序生成的查询使用相同的结构。但是我的应用程序在控制台中生成的查询结构是
"query" : {
"query_string" : {
"query" : "grails",
"fields" : [ ],
"use_dis_max" : true,
"tie_breaker" : 0.0,
"default_operator" : "and",
"auto_generate_phrase_queries" : false,
"max_determinized_states" : 10000,
"enable_position_increments" : true,
"fuzziness" : "AUTO",
"fuzzy_prefix_length" : 0,
"fuzzy_max_expansions" : 50,
"phrase_slop" : 0,
"escape" : false,
"split_on_whitespace" : true,
"boost" : 1.0
}
}
我如何在那边得到我预期的查询?任何想法 - 谁能帮助我吗?
提前致谢。
试试这个代码:
elasticSearchService.search([indices: Book, types: Book, score: true],
{
"match" {
"author"(query: "keen", "fuzziness": 4, "prefix_length": 1)
}
})
我正在尝试为我的 grails 应用程序实施弹性搜索。我使用的是 grails 3.3.6 版本,gradle wrapper 3.1,grails elasticsearch 插件是 2.4.0,elastic search 版本是 5.4.1。 我正在努力在 elasticsearchservice class 中传递搜索方法的参数。 "elasticsearchservice.search(闭包查询、参数、过滤器)"
我像这样传递参数并在
上出错match
elasticSearchService.search({match(fields: ["title", "description"],
query: q,fuzziness:'4',fuzzy_prefix_length:1)}, null,[indices: Book, types: Book, score: true])
实际上,我在这里尝试使用具有模糊性的匹配,我尝试使用 kibana 和 postman 来使用 elasticsearch _search。它在那里工作。
POST /books/code/_search
{
"query": {
"match": {
"author": {
"query": "keeen",
"fuzziness": 4,
"prefix_length": 1
}
}
}
}
我想在控制台中为我的应用程序生成的查询使用相同的结构。但是我的应用程序在控制台中生成的查询结构是
"query" : {
"query_string" : {
"query" : "grails",
"fields" : [ ],
"use_dis_max" : true,
"tie_breaker" : 0.0,
"default_operator" : "and",
"auto_generate_phrase_queries" : false,
"max_determinized_states" : 10000,
"enable_position_increments" : true,
"fuzziness" : "AUTO",
"fuzzy_prefix_length" : 0,
"fuzzy_max_expansions" : 50,
"phrase_slop" : 0,
"escape" : false,
"split_on_whitespace" : true,
"boost" : 1.0
}
}
我如何在那边得到我预期的查询?任何想法 - 谁能帮助我吗?
提前致谢。
试试这个代码:
elasticSearchService.search([indices: Book, types: Book, score: true],
{
"match" {
"author"(query: "keen", "fuzziness": 4, "prefix_length": 1)
}
})