Multiple Filter on Wild Card Search Query

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

I am using OpenSearch Client Library version - 1.3.0

Describe the issue:

I am trying to build one openSearch query in C# DotNet but could not able to achieve and need some help.

Requirement - We have 3 fields on the search screen. First field will be the wild card search and other 2 will be filter on top of WildCard Search results.

First field user can search like “1234%” - It should return some results and then apply the filter for other two field. I have tried this query but not working.

List queryContainerList = new List();
queryContainerList.Add(query.Wildcard(m => m.SourceTradeID, string.Format(“{0}*”, “1456”)));

var filters = new List<Func<QueryContainerDescriptor<Models.MOTPOpenSearchItem>, QueryContainer>>();

filters.Add(fq => fq.Terms(t => t.Field(f => f.PartitionKey).Terms(“TRADE#1c393d12-7861-5894-b6be-4cfd920f24ed”)));

        return new QueryContainerDescriptor<Models.MOTPOpenSearchItem>().Bool(
            b => b.Should(queryContainerList.ToArray).Filter(filters));

var response = await client.SearchAsync<Models.MOTPOpenSearchItem>(s => s
.Index(“Index3”)
.Query(
=> qContainer)
.Size(1000));

Configuration:

Relevant Logs or Screenshots:

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