[英]Elasticsearch Child object id search
i have a document which looks like this 我有一个看起来像这样的文件
document
{
Title:string,
Id:integer
Tags:List<Tag>
}
Tag
{
Id:integer,
Value:string,
Type:string
}
now i have parameters serchtext and tagid i need to get the results based on this parameters get all the objects which matches the search term and contains the tagid passed 现在我有参数serchtext和tagid我需要基于此参数获取结果,以获取与搜索词匹配并包含传递的tagid的所有对象
this is what i had been tryin but no luck 这就是我尝试过的,但是没有运气
var fuzzySearchResult = client.Search<Products>(s => s
.From(o)
.Size(50)
.Index(index)
.Query(filterQuery).Filter(ff=>ff.Term(t=>t.Tags.Where(id=>id.Id==tagid).FirstOrDefault().Id,Id))
);
Try this: 尝试这个:
var searchtext="term";
var tagid=1;
var documents= client.Search<Document>(x => x.Query( s =>s.Term(p=>p.Title, searchtext) && s.Term(z => z.Tags.Select(t=>t.Id), tagId)));
This query search all the Documents that have the searchtext as a part of its title and the tag with id= tagId . 该查询搜索所有具有searchtext作为其标题一部分以及id = tagId的标记的文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.