I'm trying to use Azure Cognitive Search's search.ismatch
function to filter results based on a substring match within a nested field called FieldFacet
, which is inside a collection field Fields
. However, my queries are not working as expected.
Here's my document structure (simplified):
{
"Fields": [
{
"FieldName": "Category",
"FieldFacet": "Category |#| Vehicle",
"FieldValue": "Vehicle"
},
{
"FieldName": "OtherField",
"FieldFacet": "OtherField |#| SomeValue",
"FieldValue": "SomeValue"
}
// ... more Fields objects
]
}
I've tried the following queries:
search.ismatch('value', 'Fields/FieldFacet') Fields/any(s: search.ismatch('value', 'FieldFacet', 'simple', 'any')) I expect these queries to return documents where the FieldFacet field contains the substring "value" (case-insensitive). However, I'm getting either no results or an error.
My Questions:
What is the correct syntax for using search.ismatch
on a nested field like Fields/FieldFacet?
Is it possible to use search.ismatch
within an any or all collection filter?
Are there any alternative approaches to achieve substring matching on this nested field?
I'm trying to use Azure Cognitive Search's search.ismatch
function to filter results based on a substring match within a nested field called FieldFacet
, which is inside a collection field Fields
. However, my queries are not working as expected.
Here's my document structure (simplified):
{
"Fields": [
{
"FieldName": "Category",
"FieldFacet": "Category |#| Vehicle",
"FieldValue": "Vehicle"
},
{
"FieldName": "OtherField",
"FieldFacet": "OtherField |#| SomeValue",
"FieldValue": "SomeValue"
}
// ... more Fields objects
]
}
I've tried the following queries:
search.ismatch('value', 'Fields/FieldFacet') Fields/any(s: search.ismatch('value', 'FieldFacet', 'simple', 'any')) I expect these queries to return documents where the FieldFacet field contains the substring "value" (case-insensitive). However, I'm getting either no results or an error.
My Questions:
What is the correct syntax for using search.ismatch
on a nested field like Fields/FieldFacet?
Is it possible to use search.ismatch
within an any or all collection filter?
Are there any alternative approaches to achieve substring matching on this nested field?
1 Answer
Reset to default 0You can use below kind of expression.
{
"search": "*",
"filter":"search.ismatch("Value",'Rooms/Type')"
}
Without filter
With filter
You can see the total count is 50 and filtered one is 47.
There are some cases where you may still get the results which you are not expecting, that is because the values are still mapped to the records which matching your text under collections.
Example: Let's say we have below records in index
[
{
Name:"xyz1",
Rooms:[
{
id:1,
Type: "Deluxe room"
}
]
},
{
Name:"xyz2",
Rooms:[
{
id:1,
Type: "Standard room"
}
]
},
{
Name:"xyz3",
Rooms:[
{
id:1,
Type: "Deluxe room"
},
{
id:2,
Type: "Standard room"
}
]
}
]
Here when you do filter on Type
with value Deluxe
, you would expect the output will be only first record but you get the results 1st and 3rd, because the value is having a match in 3rd record id 1
.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744652537a4585986.html
Fields/any(f: search.ismatch('value', f/FieldFacet, 'simple'))
– JayashankarGS Commented Mar 19 at 9:08