私は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は - 1つのフィルタのみ
Elasticsearch: multi_match no effect with filters