Thanks much, now i got better idea on stored & indexed works internally in
solr.
>From this i tried and modified few things to understand grouping logic.

*Schema :*
<field name="tenant_pool" type="text" stored="true" *indexed="true"*/>
<field name="type" type="text" stored="true" indexed="true"/>

*Code :*
SolrQuery q = new SolrQuery().setQuery("type:t1");
q.set(GroupParams.GROUP, true);
q.set(GroupParams.GROUP_FIELD, "tenant_pool");

*Data/Docs :*
"tenant_pool" : "P1 L1", "type"  : "t1"
"tenant_pool" : "P1 L1", "type"  : "t2"

*Output coming :*
groupValue=L1, docs=2

*Expected Output :*
groupValue=P1, docs=2
groupValue=L1 Farms, docs=2
My understanding is field is indexed so it will tokenized by space and P1
and L1 will be tokens..Each token should be one group
when we call Group=true in query. Please help me understand this better.

Thanks
Naresh

On Wed, Jan 14, 2015 at 1:32 AM, Erick Erickson <erickerick...@gmail.com>
wrote:

> bq: My question is for indexed=false, stored=true field..what is optimized
> way
> to get unique values in such field.
>
> There isn't any. To do this you'll have to read the doc from disk,
> it'll be decompressed
> along the way and then the field is read. Note that this happens
> automatically when
> you call doc.getFieldValue or similar.
>
> At the stored="true" level, you're always talking about complete documents.
> indexed="true" is about putting the field data into efficient-access
> structures.
> They're completely different beasts.
>
> your original question was:
> "Please guide me how i can tell solr not to tokenize stored field to decide
> unique groups.."
>
> Simply declare the field type you care about as a "string" type in
> schema.xml. The use a <copyFeld> directive to copy the data to the
> new type, and group on the new field.
>
> There are examples in the schema.xml of string types and copyFields that
> should help.
>
> Best,
> Erick
>
> On Tue, Jan 13, 2015 at 9:00 AM, Naresh Yadav <nyadav....@gmail.com>
> wrote:
> > Erick, my schema is same no change in that..
> > *Schema :*
> >     <field name="tenant_pool" type="text" stored="true"/>
> > my guess is i had not mentioned indexed true or false....may be default
> > indexed is true....
> >
> > My question is for indexed=false, stored=true field..what is optimized
> way
> > to get unique values in such field..
> >
> > On Tue, Jan 13, 2015 at 10:07 PM, Erick Erickson <
> erickerick...@gmail.com>
> > wrote:
> >
> >> Something is very wrong here. Have you perhaps been changing your
> >> schema without re-indexing? And I recommend you completely remove
> >> your data directory (the one with "index" and "tlog" subdirectories)
> after
> >> you change your schema.xml file.
> >>
> >> Because you're trying to group on a field that is _not_ indexed, you
> >> should be getting an error returned, something like:
> >> "can not use FieldCache on a field which is neither indexed nor has
> >> doc values: ...."
> >>
> >> As far as the tokenization comment is, just start by making the field
> you
> >> want
> >> to group on be
> >> stored="false" indexed="true" type="string"
> >>
> >> Best,
> >> Erick
> >>
> >> On Tue, Jan 13, 2015 at 5:09 AM, Naresh Yadav <nyadav....@gmail.com>
> >> wrote:
> >> > Hi jack,
> >> >
> >> > Thanks for replying, i am new to solr please guide me on this. I have
> >> many
> >> > such columns in my schema
> >> > so copy field will create lot of duplicate fields beside i do not need
> >> any
> >> > search on original field.
> >> >
> >> > My usecase is i do not want any search on tenant_pool field thats why
> i
> >> > declared it as stored field not indexed.
> >> > I just need to get unique values in this field. Please show some
> >> direction.
> >> >
> >> >
> >> > On Tue, Jan 13, 2015 at 6:16 PM, Jack Krupansky <
> >> jack.krupan...@gmail.com>
> >> > wrote:
> >> >
> >> >> That's your job. The easiest way is to do a copyField to a "string"
> >> field.
> >> >>
> >> >> -- Jack Krupansky
> >> >>
> >> >> On Tue, Jan 13, 2015 at 7:33 AM, Naresh Yadav <nyadav....@gmail.com>
> >> >> wrote:
> >> >>
> >> >> > *Schema :*
> >> >> > <field name="tenant_pool" type="text" stored="true"/>
> >> >> >
> >> >> > *Code :*
> >> >> > SolrQuery q = new SolrQuery().setQuery("*:*");
> >> >> > q.set(GroupParams.GROUP, true);
> >> >> > q.set(GroupParams.GROUP_FIELD, "tenant_pool");
> >> >> >
> >> >> > *Data :*
> >> >> > "tenant_pool" : "Baroda Farms"
> >> >> > "tenant_pool" : "Ketty Farms"
> >> >> >
> >> >> > *Output coming :*
> >> >> > groupValue=Farms, docs=2
> >> >> >
> >> >> > *Expected Output :*
> >> >> > groupValue=Baroda Farms, docs=1
> >> >> > groupValue=Ketty Farms, docs=1
> >> >> >
> >> >> > Please guide me how i can tell solr not to tokenize stored field to
> >> >> decide
> >> >> > unique groups..
> >> >> >
> >> >> > I want unique groups as exact value of field not the tokens which
> >> solr is
> >> >> > doing
> >> >> > currently.
> >> >> >
> >> >> > Thanks
> >> >> > Naresh
> >> >> >
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
>

Reply via email to