Help with match_phrase_prefix query on an embedded text field

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
opensearch: latest (2.7)
opensearch-dashboards: latest

Describe the issue:
I’m trying to execute the below match_phrase_prefix query and I don’t see any results. however, when I run match_phrase query on the same index, I see two hits. Wondering how index_prefixes works on embedded fields. Any help here would be appreciated.

Match Phrase Prefix query
{
  "query": {
		"bool":{
			"filter": [
				{
					"bool": {
						"must": [
							{
								"match_phrase_prefix": {
									"applications.name": "bind-lib"
								}
							}
						]
					}
				}
			]
		}
    }
}

Match Phrase query
{
  "query": {
		"bool":{
			"filter": [
				{
					"bool": {
						"must": [
							{
								"match_phrase": {
									"applications.name": "bind-libs"
								}
							}
						]
					}
				}
			]
		}
    }
}

Configuration:

Below is the mapping of my index
{
  "mappings": {
    "properties": {
	"platform_name": { 
		"type": "text",
		"index_prefixes": { }
	},
	"applications":  {
		"properties": {
			"name": { "type": "text", "index_prefixes": { } },
			"app_version": { "type": "keyword" },
			"publisher": { "type": "text" }
         }
       }
      }
    }
  }
}

Relevant Logs or Screenshots:

Sample document

{
	"platform_name": "Red Hat",
	"applications": [
		{	"name": "red18", "version": "v2", "publisher": "red brown ltd"},
		{	"name": "bind-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python1-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python2-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python3-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python4-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python5-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python6-libs", "version": "v1", "publisher": "red brown ltd"},
		{	"name": "python7-libs", "version": "v1", "publisher": "red brown ltd"}		
	],
}

It seems to be a bug, if only one inner object exists in applications, the match_phrase_prefix query works well.

1 Like

yep, match_phrase_prefix query also returns a hit if the text that is searched is part of the first inner object’s attribute.