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 Vijay Kokatnur <ko...@gmail.com> on 2014/03/26 20:37:34 UTC

Searching multivalue fields.

Hi,

I am bumping this thread again one last time to see if anyone has a
solution.

In it's current state, our application is storing child items as multivalue
fields.  Consider some orders, for example -


 {
OrderId:123
BookingRecordId : ["145", "987", "*234*"]
OrderLineType : ["11", "12", "*13*"]
.....
}
 {
OrderId:345
BookingRecordId : ["945", "882", "*234*"]
OrderLineType : ["1", "12", "*11*"]
.....
}
 {
OrderId:678
BookingRecordId : ["444"]
OrderLineType : ["11"]
.....
}


Here, If you look up for an Order with BookingRecordId: 234 And
OrderLineType:11.  You will get two orders with orderId : 123 and 345,
which is correct.  You have two arrays in both the orders that satisfy this
condition.

However, for OrderId:123, the value at 3rd index of OrderLineType array is
13 and not 11( this is for OrderId:345).  So orderId 123 should be
excluded. This is what I am trying to achieve.

I got some suggestions from a solr-user to use FieldsCollapsing, Join,
Block-join or string concatenation.  None of these approaches can be used
without re-indexing schema.

Has anyone found a non-invasive solution for this?

Thanks,

-Vijay

Re: Searching multivalue fields.

Posted by Jack Krupansky <ja...@basetechnology.com>.
Sounds good... for Lucene users, but for Solr users... sounds like a Jira is 
needed.

-- Jack Krupansky

-----Original Message----- 
From: Ahmet Arslan
Sent: Wednesday, March 26, 2014 4:54 PM
To: solr-user@lucene.apache.org ; kokatnur.vijay@gmail.com
Subject: Re: Searching multivalue fields.

Hi Vijay,

After reading the documentation it seems that following query is what you 
are after. It will return OrderId:345 without matching OrderId:123

SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);

Ahmet



On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com> 
wrote:
Hi Vijay,

I personally don't understand joins very well. Just a guess may be 
FieldMaskingSpanQuery could be used?

http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html


Ahmet




On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur 
<ko...@gmail.com> wrote:
Hi,

I am bumping this thread again one last time to see if anyone has a
solution.

In it's current state, our application is storing child items as multivalue
fields.  Consider some orders, for example -


{
OrderId:123
BookingRecordId : ["145", "987", "*234*"]
OrderLineType : ["11", "12", "*13*"]
.....
}
{
OrderId:345
BookingRecordId : ["945", "882", "*234*"]
OrderLineType : ["1", "12", "*11*"]
.....
}
{
OrderId:678
BookingRecordId : ["444"]
OrderLineType : ["11"]
.....
}


Here, If you look up for an Order with BookingRecordId: 234 And
OrderLineType:11.  You will get two orders with orderId : 123 and 345,
which is correct.  You have two arrays in both the orders that satisfy this
condition.

However, for OrderId:123, the value at 3rd index of OrderLineType array is
13 and not 11( this is for OrderId:345).  So orderId 123 should be
excluded. This is what I am trying to achieve.

I got some suggestions from a solr-user to use FieldsCollapsing, Join,
Block-join or string concatenation.  None of these approaches can be used
without re-indexing schema.

Has anyone found a non-invasive solution for this?

Thanks,

-Vijay 


Re: Searching multivalue fields.

Posted by Vijay Kokatnur <ko...@gmail.com>.
Since Span is the only way to solve the problem, I won't mind re-indexing.
 It's just that I have never done it before.

We've got 80G of indexed data replicated on two nodes in a cluster.  Is
there a preferred way to go about re-indexing?



On Tue, Apr 8, 2014 at 12:17 AM, Ahmet Arslan <io...@yahoo.com> wrote:

>
>
> Hi,
>
> Changing value of omitTermFreqAndPositions requires re-indexing,
> unfortunately. And I remembered that you don't want to reindex. It looks
> like we are out of options.
>
> Ahmet
>
>
> On Tuesday, April 8, 2014 12:45 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
> Yes I did restart solr, but did not re-index.  Is that necessary?  We've
> got 80G of indexed data, is there a "preferred" way of doing it without
> impacting performance?
>
>
> On Sat, Apr 5, 2014 at 9:44 AM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> > Hi,
> >
> > Did restart solr and you re-index after schema change?
> >    On Saturday, April 5, 2014 2:39 AM, Vijay Kokatnur <
> > kokatnur.vijay@gmail.com> wrote:
> >  I had already tested with omitTermFreqAndPositions="false" .  I still
> > got the same error.
> >
> > Is there something that I am overlooking?
> >
> > On Fri, Apr 4, 2014 at 2:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:
> >
> > Hi Vijay,
> >
> > Add omitTermFreqAndPositions="false"  attribute to fieldType definitions.
> >
> >     <fieldType name="string" class="solr.StrField"
> > omitTermFreqAndPositions="false" sortMissingLast="true" />
> >
> >    <fieldType name="int" class="solr.TrieIntField"
> > omitTermFreqAndPositions="false" precisionStep="0"
> > positionIncrementGap="0"/>
> >
> > You don't need termVectors  for this.
> >
> >    1.2: omitTermFreqAndPositions attribute introduced, true by default
> >             except for text fields.
> >
> > And please reply to solr user mail, so others can use the threat later
> on.
> >
> > Ahmet
> >   On Saturday, April 5, 2014 12:18 AM, Vijay Kokatnur <
> > kokatnur.vijay@gmail.com> wrote:
> >   Hey Ahmet,
> >
> > Sorry it took some time to test this.  But schema definition seem to
> > conflict with SpanQuery.  I get following error when I use Spans
> >
> >  field "OrderLineType" was indexed without position data; cannot run
> > SpanTermQuery (term=11)
> >
> > I changed field definition in the schema but can't find the right
> > attribute to set this.  My last attempt was with following definition
> >
> >    <field name="OrderLineType" type="string" indexed="true" stored="true"
> > multiValued="true" *termVectors="true" termPositions="true"
> > termOffsets="true"*/>
> >
> >  Any ideas what I am doing wrong?
> >
> > Thanks,
> > -Vijay
> >
> > On Wed, Mar 26, 2014 at 1:54 PM, Ahmet Arslan <io...@yahoo.com> wrote:
> >
> > Hi Vijay,
> >
> > After reading the documentation it seems that following query is what you
> > are after. It will return OrderId:345 without matching OrderId:123
> >
> > SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
> > SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
> > SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
> > Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);
> >
> > Ahmet
> >
> >
> >
> > On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com>
> > wrote:
> > Hi Vijay,
> >
> > I personally don't understand joins very well. Just a guess may
> > be FieldMaskingSpanQuery could be used?
> >
> >
> >
> http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html
> >
> >
> > Ahmet
> >
> >
> >
> >
> > On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <
> > kokatnur.vijay@gmail.com> wrote:
> > Hi,
> >
> > I am bumping this thread again one last time to see if anyone has a
> > solution.
> >
> > In it's current state, our application is storing child items as
> multivalue
> > fields.  Consider some orders, for example -
> >
> >
> > {
> > OrderId:123
> > BookingRecordId : ["145", "987", "*234*"]
> > OrderLineType : ["11", "12", "*13*"]
> > .....
> > }
> > {
> > OrderId:345
> > BookingRecordId : ["945", "882", "*234*"]
> > OrderLineType : ["1", "12", "*11*"]
> > .....
> > }
> > {
> > OrderId:678
> > BookingRecordId : ["444"]
> > OrderLineType : ["11"]
> > .....
> > }
> >
> >
> > Here, If you look up for an Order with BookingRecordId: 234 And
> > OrderLineType:11.  You will get two orders with orderId : 123 and 345,
> > which is correct.  You have two arrays in both the orders that satisfy
> this
> > condition.
> >
> > However, for OrderId:123, the value at 3rd index of OrderLineType array
> is
> > 13 and not 11( this is for OrderId:345).  So orderId 123 should be
> > excluded. This is what I am trying to achieve.
> >
> > I got some suggestions from a solr-user to use FieldsCollapsing, Join,
> > Block-join or string concatenation.  None of these approaches can be used
> > without re-indexing schema.
> >
> > Has anyone found a non-invasive solution for this?
> >
> > Thanks,
> >
> > -Vijay
> >
> >
> >
> >
> >
> >
> >
> >
>
>

Re: Searching multivalue fields.

Posted by Ahmet Arslan <io...@yahoo.com>.

Hi,

Changing value of omitTermFreqAndPositions requires re-indexing, unfortunately. And I remembered that you don't want to reindex. It looks like we are out of options.

Ahmet


On Tuesday, April 8, 2014 12:45 AM, Vijay Kokatnur <ko...@gmail.com> wrote:
Yes I did restart solr, but did not re-index.  Is that necessary?  We've
got 80G of indexed data, is there a "preferred" way of doing it without
impacting performance?


On Sat, Apr 5, 2014 at 9:44 AM, Ahmet Arslan <io...@yahoo.com> wrote:

> Hi,
>
> Did restart solr and you re-index after schema change?
>    On Saturday, April 5, 2014 2:39 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
>  I had already tested with omitTermFreqAndPositions="false" .  I still
> got the same error.
>
> Is there something that I am overlooking?
>
> On Fri, Apr 4, 2014 at 2:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> Hi Vijay,
>
> Add omitTermFreqAndPositions="false"  attribute to fieldType definitions.
>
>     <fieldType name="string" class="solr.StrField"
> omitTermFreqAndPositions="false" sortMissingLast="true" />
>
>    <fieldType name="int" class="solr.TrieIntField"
> omitTermFreqAndPositions="false" precisionStep="0"
> positionIncrementGap="0"/>
>
> You don't need termVectors  for this.
>
>    1.2: omitTermFreqAndPositions attribute introduced, true by default
>             except for text fields.
>
> And please reply to solr user mail, so others can use the threat later on.
>
> Ahmet
>   On Saturday, April 5, 2014 12:18 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
>   Hey Ahmet,
>
> Sorry it took some time to test this.  But schema definition seem to
> conflict with SpanQuery.  I get following error when I use Spans
>
>  field "OrderLineType" was indexed without position data; cannot run
> SpanTermQuery (term=11)
>
> I changed field definition in the schema but can't find the right
> attribute to set this.  My last attempt was with following definition
>
>    <field name="OrderLineType" type="string" indexed="true" stored="true"
> multiValued="true" *termVectors="true" termPositions="true"
> termOffsets="true"*/>
>
>  Any ideas what I am doing wrong?
>
> Thanks,
> -Vijay
>
> On Wed, Mar 26, 2014 at 1:54 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> Hi Vijay,
>
> After reading the documentation it seems that following query is what you
> are after. It will return OrderId:345 without matching OrderId:123
>
> SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
> SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
> SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
> Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);
>
> Ahmet
>
>
>
> On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com>
> wrote:
> Hi Vijay,
>
> I personally don't understand joins very well. Just a guess may
> be FieldMaskingSpanQuery could be used?
>
>
> http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html
>
>
> Ahmet
>
>
>
>
> On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
> Hi,
>
> I am bumping this thread again one last time to see if anyone has a
> solution.
>
> In it's current state, our application is storing child items as multivalue
> fields.  Consider some orders, for example -
>
>
> {
> OrderId:123
> BookingRecordId : ["145", "987", "*234*"]
> OrderLineType : ["11", "12", "*13*"]
> .....
> }
> {
> OrderId:345
> BookingRecordId : ["945", "882", "*234*"]
> OrderLineType : ["1", "12", "*11*"]
> .....
> }
> {
> OrderId:678
> BookingRecordId : ["444"]
> OrderLineType : ["11"]
> .....
> }
>
>
> Here, If you look up for an Order with BookingRecordId: 234 And
> OrderLineType:11.  You will get two orders with orderId : 123 and 345,
> which is correct.  You have two arrays in both the orders that satisfy this
> condition.
>
> However, for OrderId:123, the value at 3rd index of OrderLineType array is
> 13 and not 11( this is for OrderId:345).  So orderId 123 should be
> excluded. This is what I am trying to achieve.
>
> I got some suggestions from a solr-user to use FieldsCollapsing, Join,
> Block-join or string concatenation.  None of these approaches can be used
> without re-indexing schema.
>
> Has anyone found a non-invasive solution for this?
>
> Thanks,
>
> -Vijay
>
>
>
>
>
>
>
>


Re: Searching multivalue fields.

Posted by Vijay Kokatnur <ko...@gmail.com>.
Yes I did restart solr, but did not re-index.  Is that necessary?  We've
got 80G of indexed data, is there a "preferred" way of doing it without
impacting performance?


On Sat, Apr 5, 2014 at 9:44 AM, Ahmet Arslan <io...@yahoo.com> wrote:

> Hi,
>
> Did restart solr and you re-index after schema change?
>    On Saturday, April 5, 2014 2:39 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
>  I had already tested with omitTermFreqAndPositions="false" .  I still
> got the same error.
>
> Is there something that I am overlooking?
>
> On Fri, Apr 4, 2014 at 2:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> Hi Vijay,
>
> Add omitTermFreqAndPositions="false"  attribute to fieldType definitions.
>
>     <fieldType name="string" class="solr.StrField"
> omitTermFreqAndPositions="false" sortMissingLast="true" />
>
>    <fieldType name="int" class="solr.TrieIntField"
> omitTermFreqAndPositions="false" precisionStep="0"
> positionIncrementGap="0"/>
>
> You don't need termVectors  for this.
>
>    1.2: omitTermFreqAndPositions attribute introduced, true by default
>             except for text fields.
>
> And please reply to solr user mail, so others can use the threat later on.
>
> Ahmet
>   On Saturday, April 5, 2014 12:18 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
>   Hey Ahmet,
>
> Sorry it took some time to test this.  But schema definition seem to
> conflict with SpanQuery.  I get following error when I use Spans
>
>  field "OrderLineType" was indexed without position data; cannot run
> SpanTermQuery (term=11)
>
> I changed field definition in the schema but can't find the right
> attribute to set this.  My last attempt was with following definition
>
>    <field name="OrderLineType" type="string" indexed="true" stored="true"
> multiValued="true" *termVectors="true" termPositions="true"
> termOffsets="true"*/>
>
>  Any ideas what I am doing wrong?
>
> Thanks,
> -Vijay
>
> On Wed, Mar 26, 2014 at 1:54 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> Hi Vijay,
>
> After reading the documentation it seems that following query is what you
> are after. It will return OrderId:345 without matching OrderId:123
>
> SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
> SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
> SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
> Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);
>
> Ahmet
>
>
>
> On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com>
> wrote:
> Hi Vijay,
>
> I personally don't understand joins very well. Just a guess may
> be FieldMaskingSpanQuery could be used?
>
>
> http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html
>
>
> Ahmet
>
>
>
>
> On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
> Hi,
>
> I am bumping this thread again one last time to see if anyone has a
> solution.
>
> In it's current state, our application is storing child items as multivalue
> fields.  Consider some orders, for example -
>
>
> {
> OrderId:123
> BookingRecordId : ["145", "987", "*234*"]
> OrderLineType : ["11", "12", "*13*"]
> .....
> }
> {
> OrderId:345
> BookingRecordId : ["945", "882", "*234*"]
> OrderLineType : ["1", "12", "*11*"]
> .....
> }
> {
> OrderId:678
> BookingRecordId : ["444"]
> OrderLineType : ["11"]
> .....
> }
>
>
> Here, If you look up for an Order with BookingRecordId: 234 And
> OrderLineType:11.  You will get two orders with orderId : 123 and 345,
> which is correct.  You have two arrays in both the orders that satisfy this
> condition.
>
> However, for OrderId:123, the value at 3rd index of OrderLineType array is
> 13 and not 11( this is for OrderId:345).  So orderId 123 should be
> excluded. This is what I am trying to achieve.
>
> I got some suggestions from a solr-user to use FieldsCollapsing, Join,
> Block-join or string concatenation.  None of these approaches can be used
> without re-indexing schema.
>
> Has anyone found a non-invasive solution for this?
>
> Thanks,
>
> -Vijay
>
>
>
>
>
>
>
>

Re: Searching multivalue fields.

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi,

Did restart solr and you re-index after schema change?
On Saturday, April 5, 2014 2:39 AM, Vijay Kokatnur <ko...@gmail.com> wrote:
 
I had already tested with omitTermFreqAndPositions="false" .  I still got the same error.

Is there something that I am overlooking?


On Fri, Apr 4, 2014 at 2:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:

Hi Vijay,
>
>
>Add omitTermFreqAndPositions="false"  attribute to fieldType definitions.
>
>
>    <fieldType name="string" class="solr.StrField" omitTermFreqAndPositions="false" sortMissingLast="true" />
>
>
>
>   <fieldType name="int" class="solr.TrieIntField" omitTermFreqAndPositions="false" precisionStep="0" positionIncrementGap="0"/>
>
>
>You don't need termVectors  for this.
>
>
>   1.2: omitTermFreqAndPositions attribute introduced, true by default 
>            except for text fields.
>
>
>And please reply to solr user mail, so others can use the threat later on.
>
>Ahmet
>On Saturday, April 5, 2014 12:18 AM, Vijay Kokatnur <ko...@gmail.com> wrote:
> 
>Hey Ahmet, 
>
>
>Sorry it took some time to test this.  But schema definition seem to conflict with SpanQuery.  I get following error when I use Spans 
>
>
>field "OrderLineType" was indexed without position data; cannot run SpanTermQuery (term=11)
>
>I changed field definition in the schema but can't find the right attribute to set this.  My last attempt was with following definition 
>
>
>   <field name="OrderLineType" type="string" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true"/>
>
>
> Any ideas what I am doing wrong?
>
>
>Thanks,
>-Vijay
>
>
>On Wed, Mar 26, 2014 at 1:54 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
>Hi Vijay,
>>
>>After reading the documentation it seems that following query is what you are after. It will return OrderId:345 without matching OrderId:123
>>
>>SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
>>SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
>>SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
>>Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);
>>
>>Ahmet
>>
>>
>>
>>
>>On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>>Hi Vijay,
>>
>>I personally don't understand joins very well. Just a guess may be FieldMaskingSpanQuery could be used?
>>
>>http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html
>>
>>
>>Ahmet
>>
>>
>>
>>
>>On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <ko...@gmail.com> wrote:
>>Hi,
>>
>>I am bumping this thread again one last time to see if anyone has a
>>solution.
>>
>>In it's current state, our application is storing child items as multivalue
>>fields.  Consider some orders, for example -
>>
>>
>>{
>>OrderId:123
>>BookingRecordId : ["145", "987", "*234*"]
>>OrderLineType : ["11", "12", "*13*"]
>>.....
>>}
>>{
>>OrderId:345
>>BookingRecordId : ["945", "882", "*234*"]
>>OrderLineType : ["1", "12", "*11*"]
>>.....
>>}
>>{
>>OrderId:678
>>BookingRecordId : ["444"]
>>OrderLineType : ["11"]
>>.....
>>}
>>
>>
>>Here, If you look up for an Order with BookingRecordId: 234 And
>>OrderLineType:11.  You will get two orders with orderId : 123 and 345,
>>which is correct.  You have two arrays in both the orders that satisfy this
>>condition.
>>
>>However, for OrderId:123, the value at 3rd index of OrderLineType array is
>>13 and not 11( this is for OrderId:345).  So orderId 123 should be
>>excluded. This is what I am trying to achieve.
>>
>>I got some suggestions from a solr-user to use FieldsCollapsing, Join,
>>Block-join or string concatenation.  None of these approaches can be used
>>without re-indexing schema.
>>
>>Has anyone found a non-invasive solution for this?
>>
>>Thanks,
>>
>>-Vijay
>>
>>
>
>
>

Re: Searching multivalue fields.

Posted by Vijay Kokatnur <ko...@gmail.com>.
I had already tested with omitTermFreqAndPositions="false" .  I still got
the same error.

Is there something that I am overlooking?

On Fri, Apr 4, 2014 at 2:45 PM, Ahmet Arslan <io...@yahoo.com> wrote:

> Hi Vijay,
>
> Add omitTermFreqAndPositions="false"  attribute to fieldType definitions.
>
>     <fieldType name="string" class="solr.StrField"
> omitTermFreqAndPositions="false" sortMissingLast="true" />
>
>    <fieldType name="int" class="solr.TrieIntField"
> omitTermFreqAndPositions="false" precisionStep="0"
> positionIncrementGap="0"/>
>
> You don't need termVectors  for this.
>
>    1.2: omitTermFreqAndPositions attribute introduced, true by default
>             except for text fields.
>
> And please reply to solr user mail, so others can use the threat later on.
>
> Ahmet
>   On Saturday, April 5, 2014 12:18 AM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
>   Hey Ahmet,
>
> Sorry it took some time to test this.  But schema definition seem to
> conflict with SpanQuery.  I get following error when I use Spans
>
>  field "OrderLineType" was indexed without position data; cannot run
> SpanTermQuery (term=11)
>
> I changed field definition in the schema but can't find the right
> attribute to set this.  My last attempt was with following definition
>
>    <field name="OrderLineType" type="string" indexed="true" stored="true"
> multiValued="true" *termVectors="true" termPositions="true"
> termOffsets="true"*/>
>
>  Any ideas what I am doing wrong?
>
> Thanks,
> -Vijay
>
> On Wed, Mar 26, 2014 at 1:54 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> Hi Vijay,
>
> After reading the documentation it seems that following query is what you
> are after. It will return OrderId:345 without matching OrderId:123
>
> SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
> SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
> SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
> Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);
>
> Ahmet
>
>
>
> On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com>
> wrote:
> Hi Vijay,
>
> I personally don't understand joins very well. Just a guess may
> be FieldMaskingSpanQuery could be used?
>
>
> http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html
>
>
> Ahmet
>
>
>
>
> On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <
> kokatnur.vijay@gmail.com> wrote:
> Hi,
>
> I am bumping this thread again one last time to see if anyone has a
> solution.
>
> In it's current state, our application is storing child items as multivalue
> fields.  Consider some orders, for example -
>
>
> {
> OrderId:123
> BookingRecordId : ["145", "987", "*234*"]
> OrderLineType : ["11", "12", "*13*"]
> .....
> }
> {
> OrderId:345
> BookingRecordId : ["945", "882", "*234*"]
> OrderLineType : ["1", "12", "*11*"]
> .....
> }
> {
> OrderId:678
> BookingRecordId : ["444"]
> OrderLineType : ["11"]
> .....
> }
>
>
> Here, If you look up for an Order with BookingRecordId: 234 And
> OrderLineType:11.  You will get two orders with orderId : 123 and 345,
> which is correct.  You have two arrays in both the orders that satisfy this
> condition.
>
> However, for OrderId:123, the value at 3rd index of OrderLineType array is
> 13 and not 11( this is for OrderId:345).  So orderId 123 should be
> excluded. This is what I am trying to achieve.
>
> I got some suggestions from a solr-user to use FieldsCollapsing, Join,
> Block-join or string concatenation.  None of these approaches can be used
> without re-indexing schema.
>
> Has anyone found a non-invasive solution for this?
>
> Thanks,
>
> -Vijay
>
>
>
>
>

Re: Searching multivalue fields.

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi Vijay,

After reading the documentation it seems that following query is what you are after. It will return OrderId:345 without matching OrderId:123

SpanQuery q1  = new SpanTermQuery(new Term("BookingRecordId", "234"));
SpanQuery q2  = new SpanTermQuery(new Term("OrderLineType", "11"));
SpanQuery q2m new FieldMaskingSpanQuery(q2, "BookingRecordId");
Query q = new SpanNearQuery(new SpanQuery[]{q1, q2m}, -1, false);

Ahmet



On Wednesday, March 26, 2014 10:39 PM, Ahmet Arslan <io...@yahoo.com> wrote:
Hi Vijay,

I personally don't understand joins very well. Just a guess may be FieldMaskingSpanQuery could be used?

http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html


Ahmet




On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <ko...@gmail.com> wrote:
Hi,

I am bumping this thread again one last time to see if anyone has a
solution.

In it's current state, our application is storing child items as multivalue
fields.  Consider some orders, for example -


{
OrderId:123
BookingRecordId : ["145", "987", "*234*"]
OrderLineType : ["11", "12", "*13*"]
.....
}
{
OrderId:345
BookingRecordId : ["945", "882", "*234*"]
OrderLineType : ["1", "12", "*11*"]
.....
}
{
OrderId:678
BookingRecordId : ["444"]
OrderLineType : ["11"]
.....
}


Here, If you look up for an Order with BookingRecordId: 234 And
OrderLineType:11.  You will get two orders with orderId : 123 and 345,
which is correct.  You have two arrays in both the orders that satisfy this
condition.

However, for OrderId:123, the value at 3rd index of OrderLineType array is
13 and not 11( this is for OrderId:345).  So orderId 123 should be
excluded. This is what I am trying to achieve.

I got some suggestions from a solr-user to use FieldsCollapsing, Join,
Block-join or string concatenation.  None of these approaches can be used
without re-indexing schema.

Has anyone found a non-invasive solution for this?

Thanks,

-Vijay


Re: Searching multivalue fields.

Posted by Ahmet Arslan <io...@yahoo.com>.
Hi Vijay,

I personally don't understand joins very well. Just a guess may be FieldMaskingSpanQuery could be used?

http://blog.griddynamics.com/2011/07/solr-experience-search-parent-child.html


Ahmet



On Wednesday, March 26, 2014 9:46 PM, Vijay Kokatnur <ko...@gmail.com> wrote:
Hi,

I am bumping this thread again one last time to see if anyone has a
solution.

In it's current state, our application is storing child items as multivalue
fields.  Consider some orders, for example -


{
OrderId:123
BookingRecordId : ["145", "987", "*234*"]
OrderLineType : ["11", "12", "*13*"]
.....
}
{
OrderId:345
BookingRecordId : ["945", "882", "*234*"]
OrderLineType : ["1", "12", "*11*"]
.....
}
{
OrderId:678
BookingRecordId : ["444"]
OrderLineType : ["11"]
.....
}


Here, If you look up for an Order with BookingRecordId: 234 And
OrderLineType:11.  You will get two orders with orderId : 123 and 345,
which is correct.  You have two arrays in both the orders that satisfy this
condition.

However, for OrderId:123, the value at 3rd index of OrderLineType array is
13 and not 11( this is for OrderId:345).  So orderId 123 should be
excluded. This is what I am trying to achieve.

I got some suggestions from a solr-user to use FieldsCollapsing, Join,
Block-join or string concatenation.  None of these approaches can be used
without re-indexing schema.

Has anyone found a non-invasive solution for this?

Thanks,

-Vijay