首页 \ 问答 \ 思考狮身人面像血统搜索(Thinking sphinx ancestry searching)

思考狮身人面像血统搜索(Thinking sphinx ancestry searching)

我需要从包括子组的组中获取所有用户:

应用程序/索引/ user_index.rb

 ThinkingSphinx::Index.define :user, with: :active_record, delta: ThinkingSphinx::Deltas::SidekiqDelta do
   has groups.id
   has "CONCAT_WS('/',groups.id,groups.ancestry)", as: :group_ids, type: :integer, multi: true
end

但是当我试图搜索时:

User.search_for_ids(with_all: { group_ids: [3] })

它返回子组中的所有用户,但没有来自ID为3的组的用户

  • Sphinx 2.1.7运行undex arch linux
  • 思考斯芬克斯v3.1.1

I need to get all of the users from groups including subgroups:

app/indices/user_index.rb

 ThinkingSphinx::Index.define :user, with: :active_record, delta: ThinkingSphinx::Deltas::SidekiqDelta do
   has groups.id
   has "CONCAT_WS('/',groups.id,groups.ancestry)", as: :group_ids, type: :integer, multi: true
end

But when i'm trying to search:

User.search_for_ids(with_all: { group_ids: [3] })

It returns all of the users from subgroups, but without users from group with id 3

  • Sphinx 2.1.7 running undex arch linux
  • Thinking sphinx v3.1.1

原文:https://stackoverflow.com/questions/28449320
更新时间:2024-04-06 06:04

最满意答案

由于继承不是核心规范的一部分,我基本上使用封装来表示这一点。 所以你的[ProtoInclude]映射到:

message ProtoAlien {
   // other fields 1 thru 6 [snip]
   optional ProtoScholar ProtoScholar = 7;
}
message ProtoScholar {
   optional string Subject = 1;
}

GetProto<T>()正在v2中进行大修,因此它应该支持更多这些场景。


Since inheritance is not part of the core spec, I basically represent this using encapsulation. So your [ProtoInclude] maps to:

message ProtoAlien {
   // other fields 1 thru 6 [snip]
   optional ProtoScholar ProtoScholar = 7;
}
message ProtoScholar {
   optional string Subject = 1;
}

GetProto<T>() is undergoing an overhaul in v2, so it should support a few more of these scenarios.

相关问答

更多
  • 作为第三个选项,可以使用[XmlType]和[XmlElement(Order=n)] ......但我认为这不是你的意思; p 在“v2”中,这确实是可能的。 您不需要定义.proto - 您可以简单地告诉它在运行时要做什么,例如: var model = TypeModel.Create(); model.Add(typeof(SomeType)).Add("Foo", "Bar", "Blip"); 现在将model存储在某处(并重新使用它),并使用model.Deserialize(...)和mo ...
  • 由于继承不是核心规范的一部分,我基本上使用封装来表示这一点。 所以你的[ProtoInclude]映射到: message ProtoAlien { // other fields 1 thru 6 [snip] optional ProtoScholar ProtoScholar = 7; } message ProtoScholar { optional string Subject = 1; } GetProto()正在v2中进行大修,因此它应该支持更多这些场景。 Since ...
  • 有一个现有的已知故障与AsReference和继承,我希望很快解决。 There is an existing known glitch with AsReference and inheritance, that I hope to resolve soon.
  • 是的,protobuf-net不使用.proto文件。 事实上,对于protobuf-net,核心是在.proto支持之前写的。 您所需要的只是允许它为您要序列化的每个成员获取唯一编号。 在“v2”(未发布)中,您可以在外部执行此操作,但在可用的dll中,这意味着属性。 这可以是定制的protobuf-net属性,或者如果更方便的话,您可以使用(例如) DataContractSerializer属性: [DataContract] public class Foo { [DataMember(Or ...
  • 首先要注意的是protobuf本身不支持继承。 这没有“官方”布局。 Protobuf-net不会以您希望的方式支持序列化:选择子类型封装(而不是基本类型封装)来解决几个问题,包括: 满足Liskov替代原则 当调用者不知道/期望序列化类型时正常工作 基本上,工作(除了最简单的例子之外的任何事情,两端都准确地知道他们正在获得哪个子类型,这在很大程度上打败了多态性的点) 但是,您可以手动映射DTO,基本上您的DTO层根本不使用继承。 The first thing to note is that protob ...
  • 目前,ProtoGen只发布课程; 既然数据本质上是可变的,我会说这是合理的,但是 - 有两种选择: 编辑csharp.xslt以使用struct替换class (或复制 csharp.xslt ,并使用-t参数告诉它使用该副本) 使用它“按原样”,并明智地使用ctrl + h (低技术,我知道;但它会工作) At the current time, ProtoGen only emits classes; since the data is inherently mutable, I would say ...
  • repeated SomeType MyList = 1; 此外 - 它不是100%完美,但你可以尝试GetProto() : class Program { static void Main() { Console.WriteLine(Serializer.GetProto()); } } [ProtoContract] public class Foo { [ProtoMember(1)] public List Items ...
  • 如果你是从互操作的,那么从.proto开始是最好的选择。 对于protobuf-net,有一个命令行工具“protogen”和一个VS IDE插件,它允许你从.proto创建protobuf-net兼容的类,就像你为其他平台生成代码一样。 两者都可以在protobuf-net项目网站上找到。 如果你已经有了类,还有一些从protobuf-net类生成.proto的支持,但是这是不完整的(实际上,就v2而言,我只是在昨天写了它,所以它还没有正式下载)。 如果您正在使用跨平台,您可能还需要考虑protobuf- ...
  • Protostuff库可以序列化带注释的POJO: https ://protostuff.github.io/docs/protostuff-runtime/ The Protostuff library can serialize annotated POJOs: https://protostuff.github.io/docs/protostuff-runtime/
  • protobuf-net对扩展没有很好的支持; 你需要使用字段编号(我不认为它现在对fltColumns做任何事情)。 但是,要获得值,您应该能够使用Extensible.GetValue / TryGetValue (注意自己:在C#3.0中制作这些扩展方法)。 要设置值,请使用AppendValue - 它无法知道这是单值还是列表( repeated ),因此相同的API会处理这两种情况。 Jon的版本 (更接近Java版本)可能在这里有更好的支持。 示例(我为了简洁起见使用手写类,但 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)