You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by blopez <ba...@hotmail.com> on 2013/01/18 14:52:12 UTC

n values in one fieldType

Hi guys,

I have some specific needs for an application. Each document (identified by
docId) has several items from the same type (each one of these items
contains 6 integer values). So each Solr doc has a docId and another
multiValued attribute.

<fields>
    <field name="docId" type="int"/>
    <field name="item" type="???" multiValued="true" />
</fields>

My problem is that I don't know what fieldType I should use to implement in
the 'item' attribute, because every input query will have the 6 integer
values I told you before, to recover the docs that contains EXACTLY the 6
values.

What do you think?

Borja.



--
View this message in context: http://lucene.472066.n3.nabble.com/n-values-in-one-fieldType-tp4034552.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: n values in one fieldType

Posted by Upayavira <uv...@odoko.co.uk>.
Could you not just have six different fields? 

If you wanted greater search efficiency, maybe you could try indexing
them as described above, as strings. You could use the 'shingles' idea,
for example, if you had: 11 22 33 44 55 66 as your numbers, index the
terms:

11
11-22
11-22-33
11-22-33-44
11-22-33-44-55
11-22-33-44-55-66

as six values of a multivalued field. That way you can do an exact match
on the first four values. If you then had the individual fields indexed
as number-1 through number-6 you could do a search for 11-22-33-44 and a
range query on number-5 and another on number-6.

I'm not sure whether that would be more, or less performant than just
having six numeric fields, though.

Upayavira


On Sat, Jan 19, 2013, at 12:44 PM, blopez wrote:
> I'll always query on the set of 6 values, but in some cases, the matching
> doesn't need to be exact. 
> 
> I mean, an usual query (you know, 6 integer values) could be exact
> matching
> for the first 4 values, but then a range for the other 2 values.
> 
> What do u think would be the best way to face it?
> 
> 
> 
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/n-values-in-one-fieldType-tp4034552p4034737.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: n values in one fieldType

Posted by blopez <ba...@hotmail.com>.
I'll always query on the set of 6 values, but in some cases, the matching
doesn't need to be exact. 

I mean, an usual query (you know, 6 integer values) could be exact matching
for the first 4 values, but then a range for the other 2 values.

What do u think would be the best way to face it?



--
View this message in context: http://lucene.472066.n3.nabble.com/n-values-in-one-fieldType-tp4034552p4034737.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: n values in one fieldType

Posted by Mike Schultz <mi...@gmail.com>.
It depends on what kind of behavior you're looking for.

if for your queries the order of the 6 integer values doesn't matter you
could do:

<field name="item" type="tint" multiValued="true"/>

then you could query with ORed or ANDed integer values over that field.

If the order matters but you always query on the "set" of 6 values, then you
turn your six integers into a guid or simply HEX encode them into
singleValued string field.

Another possibility is to HEX encode the integers and separate them with
whitespace and whitespace tokenize.  Then you get a mixture of the two above
but you can also specify some locality constraints, eg. using phrase
queries, etc.

The answer really depends on the types of queries you need to be able to
respond to.

M



--
View this message in context: http://lucene.472066.n3.nabble.com/n-values-in-one-fieldType-tp4034552p4034662.html
Sent from the Solr - User mailing list archive at Nabble.com.