Sorl: Return the most recent offer for each document in a table

Sorl: Return the most recent offer for each document in a table



We are working with Cassandra and use Solr on top of it (DSE).
In a table offers we keep one offer per day for various documents which are identified by some buyerId. Each offer represent the different price which is changing each day so for each document we may have 30-60 offers.


offers



How is it possible to find from all the documents in a buyer one offer per each document which has price lower than 10$ for example ... or even just to find for each document the offer which stands closest in time from the current moment



All the fields which are mentioned in my question are indexed.
The offerDate, offerPrice, buyerId, documentId etc.



For example we have all of the following for the same Buyer1 and we want to find the offer most closed in time:


document1
document2
document3



For document1 we have:


offer1Document1.documentId=document1
offer1Document1.offerDate = today.plus(5)

offer2Document1.documentId=document1
offer2Document1.offerDate = today.plus(6)

offer3Document1.documentId=document1
offer3Document1.offerDate = today.plus(7)



For document2 we have:


offer4Document2.documentId=document2
offer4Document2.offerDate = today.plus(1)

offer5Document2.documentId=document2
offer5Document2.offerDate = today.plus(2)



For document2 we have:


offer5Document3.documentId=document3
offer6Document3.offerDate = today.plus(3)

offer7Document3.documentId=document3
offer7Document3.offerDate = today.plus(5)



When we search for all the offers for documents of Buyer1 we will list ALL of the above results - 7 results.
How would it be possible to filter out the result so we have one offer for each document which stays closest in time and result is (only one offer per document with closest date):


offer1Document1.offerDate = today.plus(5)
offer4Document2.offerDate = today.plus(1)
offer6Document3.offerDate = today.plus(3)




1 Answer
1



What are the fields do you have indexed in Solr. We can construct the search query based on the fields.






All the fields which are mentioned in my question are indexed. The offerDate, offerPrice, buyerId, etc.

– ntotomanov
Sep 19 '18 at 6:39






Added info in my initial question about indexes and example use case.

– ntotomanov
Sep 19 '18 at 6:47



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)