1
我是Elasticsearch和Nest的新手,请原谅我的无知。我想在Elasticsearch v2.3.5中使用过滤器和multi_match查询,但到目前为止我无法弄清楚。我想,一旦我为Elasticsearch工作,我应该能够将它映射到Nest。Elasticsearch v2.3.5中的过滤器和multi_match查询
下面是我的JSON数据结构:
{
"contentID":1,
"categoryID":0,
"title":"...",
"description":"...",
"contentHtml":"...",
"version":2,
"parentContentID":0,
"displayOrder":0,
"freshdeskID":0,
"isDraft":false,
"isCommentingEnabled":false,
"isArticle":false,
"grandParentContentID":0,
"isAnyParentDraft":false
}
以下是我的工作搜索查询(无任何过滤器):
POST contents/supportitem/_search?pretty=true
{
"size": 150,
"highlight": {
"fields": {
"contentHtml": {
"fragment_size": 245
}
}
},
"_source": {
"include": [
"title",
"contentID",
"description",
"thumbnailUrl",
"isDraft",
"isAnyParentDraft",
"grandParentContentID"
]
},"query": {
"multi_match": {
"type": "cross_fields",
"query": "query typed by user",
"tie_breaker": 0.3,
"fields": [
"title^1.1",
"additionalContents^1.2",
"contentHtml^1"
]
}
}
}
我想只显示在搜索结果的记录用户其中:
grandParentContentID != 0 and
isDraft != false and
isAnyParentDraft != false
我试过了可能是不同的查询但我无法弄清楚如何写这个。
夫妇不工作的查询,包括:
POST contents/supportitem/_search?pretty=true
{
"size": 150,
"highlight": {
"fields": {
"contentHtml": {
"fragment_size": 245
}
}
},
"_source": {
"include": [
"title",
"contentID",
"description",
"thumbnailUrl",
"isDraft",
"isAnyParentDraft",
"grandParentContentID"
]
},"query": {
"multi_match": {
"type": "cross_fields",
"query": "Tile map server resources",
"tie_breaker": 0.3,
"fields": [
"title^1.1",
"additionalContents^1.2",
"contentHtml^1"
]
},"filtered": {
"filter": {
"bool": {
"term": {
"isAnyParentDraft": "false"
}
}
}
}
}
}
POST contents/supportitem/_search?pretty=true
{
"size": 150,
"highlight": {
"fields": {
"contentHtml": {
"fragment_size": 245
}
}
},
"_source": {
"include": [
"title",
"contentID",
"description",
"thumbnailUrl",
"isDraft",
"isAnyParentDraft",
"grandParentContentID"
]
},"query": {
"multi_match": {
"type": "cross_fields",
"query": "Tile map server resources",
"tie_breaker": 0.3,
"fields": [
"title^1.1",
"additionalContents^1.2",
"contentHtml^1"
]
},"filtered": {
"query": {
"bool": {
"must": [
{
"field": {"isAnyParentDraft": "false"}
}
]
}
}
}
}
}
我得到"failed to parse search source. expected field name but got [START_OBJECT]"
我得到这个工作,但我无法弄清楚如何添加更多的过滤器:
POST contents/supportitem/_search?pretty=true
{
"size": 150,
"highlight": {
"fields": {
"contentHtml": {
"fragment_size": 245
}
}
},
"_source": {
"include": [
"title",
"contentID",
"description",
"thumbnailUrl",
"isDraft",
"isAnyParentDraft",
"grandParentContentID"
]
},
"query": {
"filtered": {
"query": {
"multi_match": {
"type": "cross_fields",
"query": "deleted",
"tie_breaker": 0.3,
"fields": [
"title^1.1",
"additionalContents^1.2",
"contentHtml^1"
]
}
},
"filter": {
"and": {
"filters": [
{
"term": {
"isAnyParentDraft": "false"
}
}
]
}
}
}
}
}
我提到了以下问题:
ElasticSearch with multi_match AND bool - 只有一个过滤器
Elasticsearch: multi_match no effect with filters