思考狮身人面像血统搜索(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
最满意答案
由于继承不是核心规范的一部分,我基本上使用封装来表示这一点。 所以你的
[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版本)可能在这里有更好的支持。 示例(我为了简洁起见使用手写类,但 ...