Trinity icon indicating copy to clipboard operation
Trinity copied to clipboard

How to implement like lucene where we can search fieldA = ABC AND fieldB = BCD

Open yashhema opened this issue 7 years ago • 3 comments

Hello, Say my data consists of a text and it also has some attributes (like Info1 , Info2 etc) I should be able to do search both on any word present or any of the attributes. Can you suggest how it can be implemented ?

yashhema avatar Feb 22 '18 23:02 yashhema

Hello,

You can just index those attributes like other terms, by, for example, prefixing the term with an appropriate prefix. For example, info1:dog, info2:black and then you can search for ( info1:dog OR info1:cat ) animals Or fielda:ABC AND fieldb:BCD

Does this answer your question?

markpapadakis avatar Mar 13 '18 09:03 markpapadakis

I am interested in implement document like interface (Like there is in lucene). so we can have fields of different types like int, long . So we can save dates and do range queries on dates and numbers. I saw the comments in Index.h regarding a place holder for having multiple fields. Can you provide some pointers on how should i go about implementing that.

yashhema avatar Mar 14 '18 01:03 yashhema

This is currently not supported in Trinity, although it shouldn't be hard to extend it to support it. Lucene initially supported range queries (e.g numeric ranges) by partitioning the values space and then using a simple space-partition to token scheme, though later they switched to a more generic, and more efficient, scheme where they encode a per-segment representation for a values-space and query that instead. You should be able to do that as well, or whatever else really. It's just that we didn't need that feature, and for cases where we need something similar, we have an in-memory per-document store for quick-lookups for filtering and whatnot.

markpapadakis avatar Mar 14 '18 15:03 markpapadakis