3

私は次のことをしようとしています

curl -X POST localhost:9200/magento/customer/_search?pretty=1 -d '
{
    "query": {
        "bool": {
            "must": [
                {
                    "multi_match": {
                        "query": "john",
                        "fields": [
                            "firstname"
                        ],
                        "type": "phrase_prefix"
                    }
                }
            ],
            "should": [
                {
                    "multi_match": {
                        "query": "bro",
                        "fields": [
                            "lastname"
                        ],
                        "type": "phrase_prefix",
                        "boost": 10
                    }
                },
                {
                    "multi_match": {
                        "query": "sul",
                        "fields": [
                            "lastname"
                        ],
                        "type": "phrase_prefix",
                        "boost": 1
                    }
                }
            ]
        }
    }
}
'

Johnnie BrousXXXX (編集済み) の前に、Johnnie SultXXXX の結果が返されます。

ブーストが適切に適用されていないようですか?ブール値に関するelasticsearchドキュメントをチェックしてみました: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

それらはノードのboost下にあり、bool実際には意味がありません。通常、ブール値shouldの特定の 1 つをブーストしたいのですが...?

アップデート:

インデックスの作成時にフィールド マッピングを作成していません。

の結果は次のexplainとおりです。

{
    "ok": true,
    "_index": "magento",
    "_type": "customer",
    "_id": "6043",
    "matched": true,
    "explanation": {
    "value": 2.3943894,
        "description": "product of:",
        "details": [
            {
                "value": 3.591584,
                "description": "sum of:",
                "details": [
                    {
                        "value": 1.795792,
                        "description": "sum of:",
                        "details": [
                            {
                                "value": 1.795792,
                                "description": "weight(firstname:johnnie in 8931) [PerFieldSimilarity], result of:",
                                "details": [
                                    {
                                        "value": 1.795792,
                                        "description": "score(doc=8931,freq=1.0 = termFreq=1.0\n), product of:",
                                        "details": [
                                            {
                                                "value": 0.18156901,
                                                "description": "queryWeight, product of:",
                                                "details": [
                                                    {
                                                        "value": 9.89041,
                                                        "description": "idf(docFreq=1, maxDocs=14524)"
                                                    },
                                                    {
                                                        "value": 0.018358087,
                                                        "description": "queryNorm"
                                                    }
                                                ]
                                            },
                                            {
                                                "value": 9.89041,
                                                "description": "fieldWeight in 8931, product of:",
                                                "details": [
                                                    {
                                                        "value": 1,
                                                        "description": "tf(freq=1.0), with freq of:",
                                                        "details": [
                                                            {
                                                                "value": 1,
                                                                "description": "termFreq=1.0"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "value": 9.89041,
                                                        "description": "idf(docFreq=1, maxDocs=14524)"
                                                    },
                                                    {
                                                        "value": 1,
                                                        "description": "fieldNorm(doc=8931)"
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "value": 1.795792,
                        "description": "sum of:",
                        "details": [
                            {
                                "value": 1.795792,
                                "description": "weight(lastname:sultXXXX in 8931) [PerFieldSimilarity], result of:",
                                "details": [
                                    {
                                        "value": 1.795792,
                                        "description": "score(doc=8931,freq=1.0 = termFreq=1.0\n), product of:",
                                        "details": [
                                            {
                                                "value": 0.18156901,
                                                "description": "queryWeight, product of:",
                                                "details": [
                                                    {
                                                        "value": 9.89041,
                                                        "description": "idf(docFreq=1, maxDocs=14524)"
                                                    },
                                                    {
                                                        "value": 0.018358087,
                                                        "description": "queryNorm"
                                                    }
                                                ]
                                            },
                                            {
                                                "value": 9.89041,
                                                "description": "fieldWeight in 8931, product of:",
                                                "details": [
                                                    {
                                                        "value": 1,
                                                        "description": "tf(freq=1.0), with freq of:",
                                                        "details": [
                                                            {
                                                                "value": 1,
                                                                "description": "termFreq=1.0"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        "value": 9.89041,
                                                        "description": "idf(docFreq=1, maxDocs=14524)"
                                                    },
                                                    {
                                                        "value": 1,
                                                        "description": "fieldNorm(doc=8931)"
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            {
                "value": 0.6666667,
                "description": "coord(2/3)"
            }
        ]
    }
}

s が一致していることはわかっていshouldます。s がないと、それらがある場合とは異なる最初の結果が得られるからです。

phrase_prefixこの文脈で適切に使用していることを願っています。ドキュメントからは完全にはわかりません。このページはそれらを参照しています ( http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#_match_phrase_prefix ) がquerymulti_match.

4

0 に答える 0