How to use mutli_match with same value

I'm using elastic ver7.17
My sample documents :
{
"title" : "Firmly stepping forward under the glorious banner of the Party",
"intro": "In celebration of the Party’s founding anniversary and the new spring, we proudly and firmly step forward under the glorious banner of the Party, promote the obtained achievements, strongly arouse the will and creativity of the whole people, continue to achieve greater victories in many fields, advance rapidly on the path of renewal and development, for the goal of building a society of wealthy people, a strong country, democracy, justice, and civilisation."
}
{
"title" : "Proud of the glorious Party",
"intro": "In the bustling atmosphere of the new year, the entire Party, people, and army celebrate the 93rd anniversary of the founding of the Communist Party of Vietnam - the Party of the working class, the working people, and the entire nation. With pride in the glorious Party, which has led our people to overcome all difficulties and hardships to move forward on the path of independence, freedom and development, we pledge to trust, protect and build the pure and comprehensively strong Party."
}

And my query
"query" : {
"multi_match" : {
"query" : "glorious banner",
"type" : "phrase",
"fields" : {"title","intro"},
"operator" : "and"
}
}

I want get my result the documents have both (title, introtext) contains exact string "glorious banner". Please help me!
Thanks!

Hi @anhhungxdieu

I believe the fields field should be like below:

"fields": [
        "title",
        "intro"
      ]

Doc Multi Match Query.

wow, it's my mistake
however, i have a question. I'm using php client of elasticsearch, my params like
$params = [
'index' => 'items',
'body' => [
"query" => [
"multi_match" => [
"query" => "glorious banner",
"type" => "phrase_prefix",
"fields" => ["title","intro"],
"operator" => "and"
]
]
]
];
so, results return unexpected, i don't know why?
Can you help me?
Sorry for my english

what result do you expect?
you use the and operator, so the search term must exist in the fields that you defined in "Fields".

I want result return documents contains exact glourious banner
I use combined bool with match_phrase two fields and return my result expect
Thank you!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.