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 Brian Narsi <bn...@gmail.com> on 2015/10/30 19:12:22 UTC
Sort not working as expected
I have a fieldtype setup as
<fieldType name="txt_edgngrm" class="solr.TextField" positionIncrementGap=
"100"> <analyzer type="index"> <tokenizer class=
"solr.StandardTokenizerFactory"/> <filter class=
"solr.LowerCaseFilterFactory"/> <filter class="solr.EdgeNGramFilterFactory"
minGramSize="3" maxGramSize="25"/> </analyzer> <analyzer type="query"> <
tokenizer class="solr.StandardTokenizerFactory"/> <filter class=
"solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
When I sort on this field type in ascending order I am not getting results
sorted alphabetically as expected.
Why is that?
What should I do to get the sort on?
Thanks
Re: Sort not working as expected
Posted by Erick Erickson <er...@gmail.com>.
bq: Is there no way that the existing field can be used?
In a word, "no". The indexed terms are being used for sorting. You
have a document
that has the title "aardvark zebra". The actual _tokens_ are
aardvark
zebra
solr/Lucene has no way of knowing whether these should be sorted by "a"
or "z".
The copyfield to a string type then sorting by that is a good idea, although
you may want to normalize the field (i.e. lowercase, remove punctuation,
possibly remove stopwords etc).
Best,
Erick
On Fri, Oct 30, 2015 at 3:27 PM, davidphilip cherian
<da...@gmail.com> wrote:
> You can create a copy field with string type and make it copy from this
> existing field, and sort on this new one.
> That way, you can still continue doing text search on existing one and sort
> on this new field.
>
>
>
>
>
> On Fri, Oct 30, 2015 at 3:04 PM, Brian Narsi <bn...@gmail.com> wrote:
>
>> Is there no way that the existing field can be used?
>>
>>
>> On Fri, Oct 30, 2015 at 1:42 PM, Ray Niu <ne...@gmail.com> wrote:
>>
>> > you should use string type instead of text if you want to sort
>> > alphabetically
>> >
>> > 2015-10-30 11:12 GMT-07:00 Brian Narsi <bn...@gmail.com>:
>> >
>> > > I have a fieldtype setup as
>> > >
>> > > <fieldType name="txt_edgngrm" class="solr.TextField"
>> > positionIncrementGap=
>> > > "100"> <analyzer type="index"> <tokenizer class=
>> > > "solr.StandardTokenizerFactory"/> <filter class=
>> > > "solr.LowerCaseFilterFactory"/> <filter
>> > class="solr.EdgeNGramFilterFactory"
>> > > minGramSize="3" maxGramSize="25"/> </analyzer> <analyzer type="query">
>> <
>> > > tokenizer class="solr.StandardTokenizerFactory"/> <filter class=
>> > > "solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
>> > >
>> > >
>> > > When I sort on this field type in ascending order I am not getting
>> > results
>> > > sorted alphabetically as expected.
>> > >
>> > > Why is that?
>> > >
>> > > What should I do to get the sort on?
>> > >
>> > > Thanks
>> > >
>> >
>>
Re: Sort not working as expected
Posted by davidphilip cherian <da...@gmail.com>.
You can create a copy field with string type and make it copy from this
existing field, and sort on this new one.
That way, you can still continue doing text search on existing one and sort
on this new field.
On Fri, Oct 30, 2015 at 3:04 PM, Brian Narsi <bn...@gmail.com> wrote:
> Is there no way that the existing field can be used?
>
>
> On Fri, Oct 30, 2015 at 1:42 PM, Ray Niu <ne...@gmail.com> wrote:
>
> > you should use string type instead of text if you want to sort
> > alphabetically
> >
> > 2015-10-30 11:12 GMT-07:00 Brian Narsi <bn...@gmail.com>:
> >
> > > I have a fieldtype setup as
> > >
> > > <fieldType name="txt_edgngrm" class="solr.TextField"
> > positionIncrementGap=
> > > "100"> <analyzer type="index"> <tokenizer class=
> > > "solr.StandardTokenizerFactory"/> <filter class=
> > > "solr.LowerCaseFilterFactory"/> <filter
> > class="solr.EdgeNGramFilterFactory"
> > > minGramSize="3" maxGramSize="25"/> </analyzer> <analyzer type="query">
> <
> > > tokenizer class="solr.StandardTokenizerFactory"/> <filter class=
> > > "solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
> > >
> > >
> > > When I sort on this field type in ascending order I am not getting
> > results
> > > sorted alphabetically as expected.
> > >
> > > Why is that?
> > >
> > > What should I do to get the sort on?
> > >
> > > Thanks
> > >
> >
>
Re: Sort not working as expected
Posted by Brian Narsi <bn...@gmail.com>.
Is there no way that the existing field can be used?
On Fri, Oct 30, 2015 at 1:42 PM, Ray Niu <ne...@gmail.com> wrote:
> you should use string type instead of text if you want to sort
> alphabetically
>
> 2015-10-30 11:12 GMT-07:00 Brian Narsi <bn...@gmail.com>:
>
> > I have a fieldtype setup as
> >
> > <fieldType name="txt_edgngrm" class="solr.TextField"
> positionIncrementGap=
> > "100"> <analyzer type="index"> <tokenizer class=
> > "solr.StandardTokenizerFactory"/> <filter class=
> > "solr.LowerCaseFilterFactory"/> <filter
> class="solr.EdgeNGramFilterFactory"
> > minGramSize="3" maxGramSize="25"/> </analyzer> <analyzer type="query"> <
> > tokenizer class="solr.StandardTokenizerFactory"/> <filter class=
> > "solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
> >
> >
> > When I sort on this field type in ascending order I am not getting
> results
> > sorted alphabetically as expected.
> >
> > Why is that?
> >
> > What should I do to get the sort on?
> >
> > Thanks
> >
>
Re: Sort not working as expected
Posted by Ray Niu <ne...@gmail.com>.
you should use string type instead of text if you want to sort
alphabetically
2015-10-30 11:12 GMT-07:00 Brian Narsi <bn...@gmail.com>:
> I have a fieldtype setup as
>
> <fieldType name="txt_edgngrm" class="solr.TextField" positionIncrementGap=
> "100"> <analyzer type="index"> <tokenizer class=
> "solr.StandardTokenizerFactory"/> <filter class=
> "solr.LowerCaseFilterFactory"/> <filter class="solr.EdgeNGramFilterFactory"
> minGramSize="3" maxGramSize="25"/> </analyzer> <analyzer type="query"> <
> tokenizer class="solr.StandardTokenizerFactory"/> <filter class=
> "solr.LowerCaseFilterFactory"/> </analyzer> </fieldType>
>
>
> When I sort on this field type in ascending order I am not getting results
> sorted alphabetically as expected.
>
> Why is that?
>
> What should I do to get the sort on?
>
> Thanks
>