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 Mark Baird <ja...@gmail.com> on 2007/11/22 16:19:12 UTC

Grouping multiValued fields

Let's say I have a class Item that has a collection of Sell objects.
Sell objects have two properties sellingTime (Date) and salesPerson
(String).
So in my Solr schema I have something like the following fields defined:

<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="sellingTime" type="date" indexed="true" stored="false"
multiValued="true" />
<field name="salesPerson" type="text" indexed="true" stored="false"
multiValued="true" />

An add might look like the following:

<add>
  <doc>
    <field name="id">1</field>
    <field name="sellingTime">2007-11-23T23:01:00Z</field>
    <field name="salesPerson">John Doe</field>
  </doc>
  <doc>
    <field name="id">2</field>
    <field name="sellingTime">2007-12-24T01:15:00Z</field>
    <field name="salesPerson">John Doe</field>
    <field name="sellingTime">2007-11-23T21:11:00Z</field>
    <field name="salesPerson">Jack Smith</field>
  </doc>
</add>


My problem is that all the historical sales data for the items are
getting flattened out.
I need the sellingTime and salesPerson fields to be kept as a pair
somehow, but I need to store the data as a seperate date field so that
I can do range searches.

Specifically I want to be able to do the following search:
salesPerson:"John Doe" AND sellingTime:[2007-11-23T00:0:00Z TO
2007-11-24T00:00:00Z]
Right now that query would return both items 1 and 2, but I want it to
only return item 1.

Is there some trick to get this query to work as I want it to?  Or do
I need to totally restructure my data?

Re: Grouping multiValued fields

Posted by Chris Hostetter <ho...@fucit.org>.
This thread is pretty much on point with your question.  it starts out 
with some simpler suggestions hat may work for you, and then evolves into 
a discussion of some much more complicated approaches thta (as far as i 
know) no one has ever actually implemented...

http://www.nabble.com/One-item%2C-multiple-fields%2C-and-range-queries-tf2969183.html#a8417789


: Date: Thu, 22 Nov 2007 10:19:12 -0500
: From: Mark Baird <ja...@gmail.com>
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: Grouping multiValued fields
: 
: Let's say I have a class Item that has a collection of Sell objects.
: Sell objects have two properties sellingTime (Date) and salesPerson
: (String).
: So in my Solr schema I have something like the following fields defined:
: 
: <field name="id" type="string" indexed="true" stored="true" required="true" />
: <field name="sellingTime" type="date" indexed="true" stored="false"
: multiValued="true" />
: <field name="salesPerson" type="text" indexed="true" stored="false"
: multiValued="true" />
: 
: An add might look like the following:
: 
: <add>
:   <doc>
:     <field name="id">1</field>
:     <field name="sellingTime">2007-11-23T23:01:00Z</field>
:     <field name="salesPerson">John Doe</field>
:   </doc>
:   <doc>
:     <field name="id">2</field>
:     <field name="sellingTime">2007-12-24T01:15:00Z</field>
:     <field name="salesPerson">John Doe</field>
:     <field name="sellingTime">2007-11-23T21:11:00Z</field>
:     <field name="salesPerson">Jack Smith</field>
:   </doc>
: </add>
: 
: 
: My problem is that all the historical sales data for the items are
: getting flattened out.
: I need the sellingTime and salesPerson fields to be kept as a pair
: somehow, but I need to store the data as a seperate date field so that
: I can do range searches.
: 
: Specifically I want to be able to do the following search:
: salesPerson:"John Doe" AND sellingTime:[2007-11-23T00:0:00Z TO
: 2007-11-24T00:00:00Z]
: Right now that query would return both items 1 and 2, but I want it to
: only return item 1.
: 
: Is there some trick to get this query to work as I want it to?  Or do
: I need to totally restructure my data?
: 



-Hoss