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.html
Best, Erick On Sat, Feb 16, 2019 at 7:19 AM Nicolas Paris <nicolas.pa...@riseup.net> 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 > > <hastings.recurs...@gmail.com> > > 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 <nicolas.pa...@riseup.net> > > > 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