Hi, I am new to the DSL and im using the below DSL query: {"from":0,"min_score":0.5,"query":{"bool":{"filter":[{"terms":{"extension":["bmp","jpg","tif","img","png","gif","jpeg"]}},{"terms":{"userContentType":["webpage"]}},{"terms":{"language":["en","gen"]}},{"terms":{"metaLanguage":["en"]}}],"should":[{"multi_match":{"fields":["title","description^5","partNumber","guid","metaId","keywords"],"lenient":true,"query":"technology"}}]}},"size":50,"sort":[{"userContentType.keyword":{"order":"desc"}},{"_score":{"order":"desc"}}]}
But I get no results. However if I take out one of the terms, say 'extension' or 'userContentType' it works fine.. any help would be greatly appreciated.
Indexes are generated using a separate console application, but I think i'm confident the index data is correct, otherwise it wouldn't work at all when I remove one of the terms..unless im missing something else there...
The query is generated using the NEST C# api v7.12.1
List<Func<QueryContainerDescriptor<ExpandoObject>, QueryContainer>> filters = searchModel.FilterValues
.Select(filter => (Func<QueryContainerDescriptor<ExpandoObject>, QueryContainer>)(fq => fq
.Terms(t => t
.Field(filter.FieldToSearch.Trim())
.Terms(filter.Values)))).ToList();
searchDescriptor
.Query(q => q
.Bool(b => b
.Should(s => s
.MultiMatch(m => m
.Fields( _elasticSearchServiceHelper.GetFieldsToSearch(searchModel.FieldsToSearch))
.Query(searchModel.SearchTerm)
.Lenient(true)))
.Filter(filters)))
.Sort(SortDescriptor);
I know it's tedious, but without a reproducible example it's hard to help. The document without mapping is not helpful and I for example cannot do any .NET code execution to reproduce this, so I would need to raw JSON of document creation/indexing, index creation and query.
Also, please do not paste screenshots, but rather code snippets, as not everyone is able to read those.
I cant help much with the json indexing/creating unfortunately.
Apologies, I wont paste images again, my bad.
Just a hunch here, but could the query be doing a AND for each terms hence the no results?
If so, I think I may have incorrectly assumed that the should part of the query handled this..in which case would I need to make the terms OR based?
Hi, just a quick update.
I still couldn't figure this out, ultimately in the end, I had to make sure that I was only ever using up to a maximum of 3 terms per query, this meant updating my indexes to have an attributes field that contained a collection of fields that I wanted to search on, this seems to work fine now.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.