lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Dall'Osto <tenacious...@yahoo.it.INVALID>
Subject Re: Get results in multiple orders (multiple boosts)
Date Fri, 18 Aug 2017 07:21:50 GMT

Yes, of course, and excuse me for the misunderstanding.


In my scenario I have to display a list with hundreds of documents.
An user can show this documents in a particular order, this order is decided by user in a
settings view.


Order levels are for example:
1) Order by category, as most important.
2) Order by source, as second level.
3) Order by date (ascending or descending).
4) Order by title (ascending or descending).


For category order, in settings view, user has an box with a list of all categories available
for him/her.
User drag&drop elements of the list to set in the favorite order.
Same thing for sources.


Let me show you an example of the list:
User show home page with a list of that documents:


documents : [
    0 => {
        "id" : 100,
        "title" : "Title A",
        "category" : 10,
        "source" : 3,
        "date" : "2017-08-17",
    },
    1 => {
        "id" : 101,
        "title" : "Title B",
        "category" : 50,
        "source" : 1,
        "date" : "2017-08-17",
    },
    2 => {
        "id" : 102,
        "title" : "Title A",
        "category" : 10,
        "source" : 5,
        "date" : "2017-08-17",
    },
    3 => {
        "id" : 103,
        "title" : "Title C",
        "category" : 10,
        "source" : 5,
        "date" : "2017-07-23",
    },
    4 => {
        "id" : 104,
        "title" : "Title C",
        "category" : 4,
        "source" : 3,
        "date" : "2017-08-17",
    },
];




This user has the category order like:
category_order: [
    0 => 10,
    1 => 4,
    2 => 50,
]


... and source order like:
source_order: [
    0 => 5,
    1 => 3,
    2 => 1000,
    3 => 1
]


Now, this user has specified in settings that he/she will show:
1) first documents order by category
2) then, user will have these documents in source order
3) then, order by date DESCENDING (newest first)
4) and finally by name as last order ASCENDING (A to Z).


I have to query documents from Solr with these orders.
The results would be like
1) document with id = 102,
2) document with id = 103,
3) document with id = 100,
4) document with id = 104,
5) document with id = 101,


I hope I explained it well.


PS: If you need, I wrote a custom sort function that sort elements of a list (instance object
of jQuery plugin List.js) in the correct order I need.
It's JavasScript code, made before I implement Solr pagination.
With Solr pagination it don't work.
If you need it let me know, I will post it on Pastebin.


Thank you



Luca





On Wednesday, August 16, 2017 12:39 PM, Rick Leir <rleir@leirtech.com> wrote:


 

 Luca
Can you give me an example? If category_id is 9500, what would you want to sort on? -- Rick

On August 16, 2017 5:19:56 AM EDT, Luca Dall'Osto <tenaciousd93@yahoo.it.INVALID> wrote:
>Hello Rick,
>I have no algorithm: user choose the order of the categories, and the
>sources, For example:
>
>
>For Category:
>- at position 0 category_id 9500.
>- at position 1 category_id 10.
>- at position 2 category_ud 555.
>(etc...)
>
>
>For Source:
>
>- at position 0 source_id 12.
>- at position 1 source_id 30.
>
>- at position 2 source_id 3.
>
>(etc...)
>
>
>After that, user decide what kind of sort apply.
>For example: fist by DATE, then by CATEGORY, then by SOURCE and then by
>NAME.
>I have 1 array with all category Ids with correct order decided by user
>and another one with source Ids in correct order decided by user.
>Then I have another array that specify the sort type (like example,
>user should ask documents ordered by DATE first, then by CATEGORY,
>etc... )
>Natural sort order could be fine only for DATE and NAME, but for
>CATEGORY and SOURCE I have to use the array with ids sorted by user.
>Thanks!
>
>Luca 
>
>On Tuesday, August 8, 2017 6:54 PM, Rick Leir <rleir@leirtech.com>
>wrote:
> 
>
> Luca,
>What is the algorithm for the custom sort order?  -- Rick
>
>On August 7, 2017 6:38:49 AM EDT, Luca Dall'Osto
><tenaciousd93@yahoo.it.INVALID> wrote:
>>Hello Rick,
>>thanks for your answer.
>>Yes, I compose solr query from frontend request, but I'm not able to
>>sort by a custom order, only by natural order (for example:
>>sort=category desc, source desc, /*...*/ ).
>>How do you set a custom sort order in solr?
>>Thanks
>>
>>Luca
>>
>>
>> 
>>
>>On Friday, August 4, 2017 7:41 PM, Rick Leir <rleir@leirtech.com>
>>wrote:
>> 
>>
>> Luca
>>I hope you have a web app in front of Solr. It could accept parameters
>>from the browser, then construct the query as necessary to do your
>>sorting. Cheers -- Rick
>>
>>On August 4, 2017 5:32:31 AM EDT, Luca Dall'Osto
>><tenaciousd93@yahoo.it.INVALID> wrote:
>>>Hello,
>>>sorry for the late, I was out of my home.
>>>
>>>
>>>In response to Rick: 
>>>I can't do that because: 
>>>1) each user should have multiple sort (for example user "A" can sort
>>>by date and then by category and then by name ...) .
>>>2) the sort is not natural sort: user has a custom order for a field
>>>(for example sorting category field of user "A" could be category 10
>>at
>>>position 1, category 2 at position 2, category 9500 at position 3,
>>>category 40 at position 5 ...).
>>>
>>>
>>>In response to Susheel:have you done an example? 
>>>
>>>Thanks for your response.
>>>
>>>Luca
>>>
>>> 
>>>
>>>On Thursday, July 20, 2017 4:10 AM, Susheel Kumar
>>><susheel2777@gmail.com> wrote:
>>> 
>>>
>>> Let me try to put an example for custom sort.
>>>
>>>On Wed, Jul 19, 2017 at 6:34 AM, Rick Leir <rleir@leirtech.com>
>wrote:
>>>
>>>> Luca,
>>>> You can pass a sort parameter in the query. User A could
>>>sort=date%20desc
>>>> and user b could sort=foofield%20asc.
>>>>
>>>> Maybe query functions can also help with this. Cheers -- Rick
>>>>
>>>> On July 19, 2017 4:39:59 AM EDT, Luca Dall'Osto
>>>> <tenaciousd93@yahoo.it.INVALID> wrote:
>>>> >Hello,The problem of build an index is that each user has a custom
>>>> >source order and category order: are not static orders (for
>example
>>>> >user X could have category:5 as most important category but user Y
>>>> >could have category:9 as most important).
>>>> >Has anyone ever written a custom sort function in solr?Maybe a
>link
>>>of
>>>> >a tutorial or an example could be very helpful. Thanks
>>>> >
>>>> >Luca
>>>> >
>>>> >On Tuesday, July 18, 2017 4:18 PM, alessandro.benedetti
>>>> ><a.benedetti@sease.io> wrote:
>>>> >
>>>> >
>>>> >"I have different "sort preferences", so I can't build a index and
>>>use
>>>> >for
>>>> >sorting.Maybe I have to sort by category then by source and by
>>>language
>>>> >or
>>>> >by source, then by category and by date"
>>>> >
>>>> >I would like to focus on this bit.
>>>> >It is ok to go for a custom function and sort at query time, but I
>>>am
>>>> >curious to explore why an index time solution should not be ok.
>>>> >You can have these distinct fields :
>>>> >source_priority
>>>> >language_priority
>>>> >category_priority
>>>> >ect
>>>> >
>>>> >This values can be assigned at the documents at indexing time (
>>>using
>>>> >for
>>>> >example a custom update request processor).
>>>> >Then at query time you can easily sort on those values in a multi
>>>> >layered
>>>> >approach :
>>>> >sort:source_priority desc, category_priority  desc
>>>> >Of course, if the priority for a source changes quite often or if
>>>it's
>>>> >user
>>>> >dependent, a query time solution would be preferred.
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >-----
>>>> >---------------
>>>> >Alessandro Benedetti
>>>> >Search Consultant, R&D Software Engineer, Director
>>>> >Sease Ltd. - www.sease.io
>>>> >--
>>>> >View this message in context:
>>>> >http://lucene.472066.n3.nabble.com/Get-results-in-
>>>> multiple-orders-multiple-boosts-tp4346304p4346559.html
>>>> >Sent from the Solr - User mailing list archive at Nabble.com.
>>>> >
>>>> >
>>>> >
>>>>
>>>> --
>>>> Sorry for being brief. Alternate email is rickleir at yahoo dot com
>>>
>>>
>>>  
>>
>>-- 
>>Sorry for being brief. Alternate email is rickleir at yahoo dot com
>>
>>  
>
>-- 
>Sorry for being brief. Alternate email is rickleir at yahoo dot com
>
>  

-- 
Sorry for being brief. Alternate email is rickleir at yahoo dot com

   
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message