简体   繁体   English

Elasticsearch子对象ID搜索

[英]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.

相关问题 ElasticSearch使用ElasticSearch NEST .NET库为子对象设置父对象 - ElasticSearch set parent for child object using ElasticSearch NEST .NET library 对象内部的id字段,NEST用于elasticsearch - id field inside object, NEST for elasticsearch 如何在 ElasticSearch 中仅选择子对象的匹配字段? - How to select only matching fields of child object in ElasticSearch? 构建表达式以在对象的子属性(集合)中搜索 - Building Expression to search in child properies (collection) of object NHibernate子对象的ID问题 - NHibernate child object's ID problem 在NHibernate中通过ID或父对象获取子对象? - Get child objects by id or parent object in NHibernate? Rest API: Parent and Child object modelling, child Id and child object within JSON via Newtonsoft.Json - Rest API: Parent and Child object modelling, child Id and child object within JSON via Newtonsoft.Json 根据属性id搜索并获取XML节点的所有子节点 - Search and get all child nodes of XML node base on attribute id Enity框架未将新创建的对象ID分配给子对象 - Enity framework not assigning newly created object id to child object 使用 PIT(时间点)ID 和 Search_After API -NEST ElasticSearch - Using PIT (Point in Time) ID and Search_After API -NEST ElasticSearch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM