|
|
Hi
I have a numeric field (say "weight") and I d'like to be able to get
results sorted.
q=kind:animal weight:50
pf=kind^2 weight^3
would return:
name=dog, kind=animal, weight=51
name=tiger, kind=animal,weight=150
name=elephant, kind=animal,weight=2000
In other terms how to deal with numeric fields ?
My first idea is to encode numeric into letters (one x per value)
dog xxxxxxxxxxxxxxxxxxxxxxxxx
tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
elephant xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
and the query would be
kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
How to deal with numeric fields ?
Thanks
--
nicolas
|
|
Not clearly understanding your question here. if your query is
q=kind:animal weight:50 you will get no results, as nothing matches
(assuming a q.op of AND)
On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
wrote:
> Hi
>
> I have a numeric field (say "weight") and I d'like to be able to get
> results sorted.
> q=kind:animal weight:50
> pf=kind^2 weight^3
>
> would return:
> name=dog, kind=animal, weight=51
> name=tiger, kind=animal,weight=150
> name=elephant, kind=animal,weight=2000
>
>
> In other terms how to deal with numeric fields ?
>
> My first idea is to encode numeric into letters (one x per value)
> dog xxxxxxxxxxxxxxxxxxxxxxxxx
> tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> elephant
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> and the query would be
> kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
>
>
> How to deal with numeric fields ?
>
> Thanks
> --
> nicolas
>
|
|
Hi Niclolas,
Solr has no difficulty sorting on numeric fields if they are indexed as a
numeric type. Just use "&sort=weight asc" If you're field is indexed as
text of course it won't sort properly, but then you should fix your schema.
-Gus
On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
wrote:
> Not clearly understanding your question here. if your query is
> q=kind:animal weight:50 you will get no results, as nothing matches
> (assuming a q.op of AND)
>
>
> On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
> wrote:
>
> > Hi
> >
> > I have a numeric field (say "weight") and I d'like to be able to get
> > results sorted.
> > q=kind:animal weight:50
> > pf=kind^2 weight^3
> >
> > would return:
> > name=dog, kind=animal, weight=51
> > name=tiger, kind=animal,weight=150
> > name=elephant, kind=animal,weight=2000
> >
> >
> > In other terms how to deal with numeric fields ?
> >
> > My first idea is to encode numeric into letters (one x per value)
> > dog xxxxxxxxxxxxxxxxxxxxxxxxx
> > tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > elephant
> >
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > and the query would be
> > kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
> >
> >
> > How to deal with numeric fields ?
> >
> > Thanks
> > --
> > nicolas
> >
>
--
http://www.the111shift.com
|
|
Hi
Thanks.
To clarify, I don't want to sort by numeric fields, instead, I d'like to
get sort by distance to my query.
On Thu, Feb 14, 2019 at 06:20:19PM -0500, Gus Heck wrote:
> Hi Niclolas,
>
> Solr has no difficulty sorting on numeric fields if they are indexed as a
> numeric type. Just use "&sort=weight asc" If you're field is indexed as
> text of course it won't sort properly, but then you should fix your schema.
>
> -Gus
>
> On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
> wrote:
>
> > Not clearly understanding your question here. if your query is
> > q=kind:animal weight:50 you will get no results, as nothing matches
> > (assuming a q.op of AND)
> >
> >
> > On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
> > wrote:
> >
> > > Hi
> > >
> > > I have a numeric field (say "weight") and I d'like to be able to get
> > > results sorted.
> > > q=kind:animal weight:50
> > > pf=kind^2 weight^3
> > >
> > > would return:
> > > name=dog, kind=animal, weight=51
> > > name=tiger, kind=animal,weight=150
> > > name=elephant, kind=animal,weight=2000
> > >
> > >
> > > In other terms how to deal with numeric fields ?
> > >
> > > My first idea is to encode numeric into letters (one x per value)
> > > dog xxxxxxxxxxxxxxxxxxxxxxxxx
> > > tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > > elephant
> > >
> > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > >
> > > and the query would be
> > > kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
> > >
> > >
> > > How to deal with numeric fields ?
> > >
> > > Thanks
> > > --
> > > nicolas
> > >
> >
>
>
> --
> http://www.the111shift.com--
nicolas
|
|
Well, you haven't defined "distance" so it's hard to say. But what you
_probably_ want is
to sort by function. See:
https://lucene.apache.org/solr/guide/6_6/function-queries.htmlBest,
Erick
On Sat, Feb 16, 2019 at 7:19 AM Nicolas Paris < [hidden email]> wrote:
>
> Hi
>
> Thanks.
> To clarify, I don't want to sort by numeric fields, instead, I d'like to
> get sort by distance to my query.
>
>
> On Thu, Feb 14, 2019 at 06:20:19PM -0500, Gus Heck wrote:
> > Hi Niclolas,
> >
> > Solr has no difficulty sorting on numeric fields if they are indexed as a
> > numeric type. Just use "&sort=weight asc" If you're field is indexed as
> > text of course it won't sort properly, but then you should fix your schema.
> >
> > -Gus
> >
> > On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
> > wrote:
> >
> > > Not clearly understanding your question here. if your query is
> > > q=kind:animal weight:50 you will get no results, as nothing matches
> > > (assuming a q.op of AND)
> > >
> > >
> > > On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
> > > wrote:
> > >
> > > > Hi
> > > >
> > > > I have a numeric field (say "weight") and I d'like to be able to get
> > > > results sorted.
> > > > q=kind:animal weight:50
> > > > pf=kind^2 weight^3
> > > >
> > > > would return:
> > > > name=dog, kind=animal, weight=51
> > > > name=tiger, kind=animal,weight=150
> > > > name=elephant, kind=animal,weight=2000
> > > >
> > > >
> > > > In other terms how to deal with numeric fields ?
> > > >
> > > > My first idea is to encode numeric into letters (one x per value)
> > > > dog xxxxxxxxxxxxxxxxxxxxxxxxx
> > > > tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > > > elephant
> > > >
> > > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > > >
> > > > and the query would be
> > > > kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
> > > >
> > > >
> > > > How to deal with numeric fields ?
> > > >
> > > > Thanks
> > > > --
> > > > nicolas
> > > >
> > >
> >
> >
> > --
> > http://www.the111shift.com>
> --
> nicolas
|
|
Sounds like you need to use code and post process your results as it sounds too specific to your use case. Just my opinion, unless you want to get into spacial queries which is a whole different animal and something I don’t think many have experience with, including myself
> On Feb 16, 2019, at 10:10 AM, Nicolas Paris < [hidden email]> wrote:
>
> Hi
>
> Thanks.
> To clarify, I don't want to sort by numeric fields, instead, I d'like to
> get sort by distance to my query.
>
>
>> On Thu, Feb 14, 2019 at 06:20:19PM -0500, Gus Heck wrote:
>> Hi Niclolas,
>>
>> Solr has no difficulty sorting on numeric fields if they are indexed as a
>> numeric type. Just use "&sort=weight asc" If you're field is indexed as
>> text of course it won't sort properly, but then you should fix your schema.
>>
>> -Gus
>>
>> On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
>> wrote:
>>
>>> Not clearly understanding your question here. if your query is
>>> q=kind:animal weight:50 you will get no results, as nothing matches
>>> (assuming a q.op of AND)
>>>
>>>
>>> On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
>>> wrote:
>>>
>>>> Hi
>>>>
>>>> I have a numeric field (say "weight") and I d'like to be able to get
>>>> results sorted.
>>>> q=kind:animal weight:50
>>>> pf=kind^2 weight^3
>>>>
>>>> would return:
>>>> name=dog, kind=animal, weight=51
>>>> name=tiger, kind=animal,weight=150
>>>> name=elephant, kind=animal,weight=2000
>>>>
>>>>
>>>> In other terms how to deal with numeric fields ?
>>>>
>>>> My first idea is to encode numeric into letters (one x per value)
>>>> dog xxxxxxxxxxxxxxxxxxxxxxxxx
>>>> tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>> elephant
>>>>
>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>>
>>>> and the query would be
>>>> kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
>>>>
>>>>
>>>> How to deal with numeric fields ?
>>>>
>>>> Thanks
>>>> --
>>>> nicolas
>>>>
>>>
>>
>>
>> --
>> http://www.the111shift.com>
> --
> nicolas
|
|
q=kind:animal&wantedweight=50&sort=abs(sub(weight,wantedweight)) asc
Jan Høydahl
> 16. feb. 2019 kl. 17:08 skrev Dave < [hidden email]>:
>
> Sounds like you need to use code and post process your results as it sounds too specific to your use case. Just my opinion, unless you want to get into spacial queries which is a whole different animal and something I don’t think many have experience with, including myself
>
>> On Feb 16, 2019, at 10:10 AM, Nicolas Paris < [hidden email]> wrote:
>>
>> Hi
>>
>> Thanks.
>> To clarify, I don't want to sort by numeric fields, instead, I d'like to
>> get sort by distance to my query.
>>
>>
>>> On Thu, Feb 14, 2019 at 06:20:19PM -0500, Gus Heck wrote:
>>> Hi Niclolas,
>>>
>>> Solr has no difficulty sorting on numeric fields if they are indexed as a
>>> numeric type. Just use "&sort=weight asc" If you're field is indexed as
>>> text of course it won't sort properly, but then you should fix your schema.
>>>
>>> -Gus
>>>
>>> On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
>>> wrote:
>>>
>>>> Not clearly understanding your question here. if your query is
>>>> q=kind:animal weight:50 you will get no results, as nothing matches
>>>> (assuming a q.op of AND)
>>>>
>>>>
>>>> On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
>>>> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I have a numeric field (say "weight") and I d'like to be able to get
>>>>> results sorted.
>>>>> q=kind:animal weight:50
>>>>> pf=kind^2 weight^3
>>>>>
>>>>> would return:
>>>>> name=dog, kind=animal, weight=51
>>>>> name=tiger, kind=animal,weight=150
>>>>> name=elephant, kind=animal,weight=2000
>>>>>
>>>>>
>>>>> In other terms how to deal with numeric fields ?
>>>>>
>>>>> My first idea is to encode numeric into letters (one x per value)
>>>>> dog xxxxxxxxxxxxxxxxxxxxxxxxx
>>>>> tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>>> elephant
>>>>>
>>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>>>
>>>>> and the query would be
>>>>> kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
>>>>>
>>>>>
>>>>> How to deal with numeric fields ?
>>>>>
>>>>> Thanks
>>>>> --
>>>>> nicolas
>>>>>
>>>>
>>>
>>>
>>> --
>>> http://www.the111shift.com>>
>> --
>> nicolas
|
|
hi
On Sun, Feb 17, 2019 at 09:40:43AM +0100, Jan Høydahl wrote:
> q=kind:animal&wantedweight=50&sort=abs(sub(weight,wantedweight)) asc
*sort function* looks a great way.
I did not mention very clearly I d'like to use edsimax and add some
weight to some fields (such *description* in the below example). So
*sorting* looks not sufficient.
After playing around with distance functions it turns out this one looks
quite sufficient:
?defType=edismax&q=kind:animal&carnivore&qf=description^3&boost=div(1,abs(sub(weight,50)))
this means: "give me all animals having carnivore in the description, and
order them given their weight is near 50 kg and carnivore is relevant
in the description"
Does this make sence ?
On Sun, Feb 17, 2019 at 09:40:43AM +0100, Jan Høydahl wrote:
> q=kind:animal&wantedweight=50&sort=abs(sub(weight,wantedweight)) asc
>
> Jan Høydahl
>
> > 16. feb. 2019 kl. 17:08 skrev Dave < [hidden email]>:
> >
> > Sounds like you need to use code and post process your results as it sounds too specific to your use case. Just my opinion, unless you want to get into spacial queries which is a whole different animal and something I don’t think many have experience with, including myself
> >
> >> On Feb 16, 2019, at 10:10 AM, Nicolas Paris < [hidden email]> wrote:
> >>
> >> Hi
> >>
> >> Thanks.
> >> To clarify, I don't want to sort by numeric fields, instead, I d'like to
> >> get sort by distance to my query.
> >>
> >>
> >>> On Thu, Feb 14, 2019 at 06:20:19PM -0500, Gus Heck wrote:
> >>> Hi Niclolas,
> >>>
> >>> Solr has no difficulty sorting on numeric fields if they are indexed as a
> >>> numeric type. Just use "&sort=weight asc" If you're field is indexed as
> >>> text of course it won't sort properly, but then you should fix your schema.
> >>>
> >>> -Gus
> >>>
> >>> On Thu, Feb 14, 2019 at 4:10 PM David Hastings < [hidden email]>
> >>> wrote:
> >>>
> >>>> Not clearly understanding your question here. if your query is
> >>>> q=kind:animal weight:50 you will get no results, as nothing matches
> >>>> (assuming a q.op of AND)
> >>>>
> >>>>
> >>>> On Thu, Feb 14, 2019 at 4:06 PM Nicolas Paris < [hidden email]>
> >>>> wrote:
> >>>>
> >>>>> Hi
> >>>>>
> >>>>> I have a numeric field (say "weight") and I d'like to be able to get
> >>>>> results sorted.
> >>>>> q=kind:animal weight:50
> >>>>> pf=kind^2 weight^3
> >>>>>
> >>>>> would return:
> >>>>> name=dog, kind=animal, weight=51
> >>>>> name=tiger, kind=animal,weight=150
> >>>>> name=elephant, kind=animal,weight=2000
> >>>>>
> >>>>>
> >>>>> In other terms how to deal with numeric fields ?
> >>>>>
> >>>>> My first idea is to encode numeric into letters (one x per value)
> >>>>> dog xxxxxxxxxxxxxxxxxxxxxxxxx
> >>>>> tiger xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >>>>> elephant
> >>>>>
> >>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >>>>>
> >>>>> and the query would be
> >>>>> kind:animal, weight:xxxxxxxxxxxxxxxxxxxxxxx
> >>>>>
> >>>>>
> >>>>> How to deal with numeric fields ?
> >>>>>
> >>>>> Thanks
> >>>>> --
> >>>>> nicolas
> >>>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> http://www.the111shift.com> >>
> >> --
> >> nicolas
>
--
nicolas
|
|