Re: Sorting on multi-valued field
Hi Peri, You cannot do sort on multi-valued field. It should be set to false. On Tue, Feb 24, 2015 at 8:07 PM, Peri Subrahmanya peri.subrahma...@htcinc.com wrote: All, Is there a way sorting can work on a multi-valued field or does it always have to be “false” for it to work. Thanks -Peri *** DISCLAIMER *** This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind HTC Global Services to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Re: Sorting on multi-valued field
fwiw, open solr jira https://issues.apache.org/jira/browse/SOLR-2522 pls vote however, everything seems done at lucene level https://issues.apache.org/jira/browse/LUCENE-5454 On Tue, Feb 24, 2015 at 6:11 PM, Nitin Solanki nitinml...@gmail.com wrote: Hi Peri, You cannot do sort on multi-valued field. It should be set to false. On Tue, Feb 24, 2015 at 8:07 PM, Peri Subrahmanya peri.subrahma...@htcinc.com wrote: All, Is there a way sorting can work on a multi-valued field or does it always have to be “false” for it to work. Thanks -Peri *** DISCLAIMER *** This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind HTC Global Services to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. -- Sincerely yours Mikhail Khludnev Principal Engineer, Grid Dynamics http://www.griddynamics.com mkhlud...@griddynamics.com
Sorting on multi-valued field
All, Is there a way sorting can work on a multi-valued field or does it always have to be “false” for it to work. Thanks -Peri *** DISCLAIMER *** This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind HTC Global Services to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Re: Sorting on multi-valued field
The usual strategy is to have an UpdateRequestProcessor chain that will copy the field and keep only one value from it, specifically for sort. There is a whole collection of URPs to help you choose which value to keep, as well as how to provide a default. You can see the full list at: http://www.solr-start.com/info/update-request-processors/#FieldValueSubsetUpdateProcessorFactory Also, if you are on the recent Solr, consider enabling docValues on that target single-value field, it's better for sorting. You can have other flags (stored,indexed) set to false, as you will not be using the field for anything else. Regards, Alex. Solr Analyzers, Tokenizers, Filters, URPs and even a newsletter: http://www.solr-start.com/ On 24 February 2015 at 09:37, Peri Subrahmanya peri.subrahma...@htcinc.com wrote: All, Is there a way sorting can work on a multi-valued field or does it always have to be “false” for it to work. Thanks -Peri *** DISCLAIMER *** This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind HTC Global Services to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Re: Sorting on multi-valued field
How about creating two fields for the multi-valued field. First, grab the higher and lower values of the multi-valued field by using natural sort order. Then use the first field to store the highest order value. Use second field to store lowest order value. Both these fields are single valued. Now based on the sort order of the original field, override the sort field in the handler side before executing the query. Thanks Shyamsunder Sent from my iPhone On Feb 24, 2015, at 11:28 AM, Alexandre Rafalovitch arafa...@gmail.com wrote: The usual strategy is to have an UpdateRequestProcessor chain that will copy the field and keep only one value from it, specifically for sort. There is a whole collection of URPs to help you choose which value to keep, as well as how to provide a default. You can see the full list at: http://www.solr-start.com/info/update-request-processors/#FieldValueSubsetUpdateProcessorFactory Also, if you are on the recent Solr, consider enabling docValues on that target single-value field, it's better for sorting. You can have other flags (stored,indexed) set to false, as you will not be using the field for anything else. Regards, Alex. Solr Analyzers, Tokenizers, Filters, URPs and even a newsletter: http://www.solr-start.com/ On 24 February 2015 at 09:37, Peri Subrahmanya peri.subrahma...@htcinc.com wrote: All, Is there a way sorting can work on a multi-valued field or does it always have to be “false” for it to work. Thanks -Peri *** DISCLAIMER *** This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind HTC Global Services to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
Re: Sorting by multi-valued field
Hey Guys, Thanks a lot for your input! But my interpretation of the next start time is that it wsa dependent on the value of NOW when the query was executed (ie: some of the indexed values may be in the past) in which case that approach wouldn't work. If the query was always a NOW query, there would be no problem. I could just re-index the events once a day and re-adjust the value for next start. The problem is that the user has a calendar/datepicker view and can choose a future date within the next year and view events ordered by next-start after that specific day. As I see it now, I have two options: 1) Create a custom function query as suggested by Chris 2) Index seperate documents for every start time and group them by event at query time (3) A third possibility I thought of was to add a field for every day of the year to each document that contains the next-start date for that particular day: next_start_20121212_dt etc. Then I could order by the dynamic field. But as only some of my events are recurring and few of those recurring over long periods of time I think it does not make too much sense. I might go for option two for now as I'm not a big fan of creating (and especially maintaining) custom components. Or is someone with an even better idea out there? ;) Cheers, Thomas On Tue, Dec 4, 2012 at 11:34 PM, Chris Hostetter hossman_luc...@fucit.orgwrote: : But it would be a lot harder than either splitting them out into : separate docs, or writing code to re-index docs when one of their : 'next-event' dates passes, with a new single valued 'next-event' field. : Less efficient, but easier to write/manage. Don't get me wrong -- if you can determine at index time which single value you wnat to use to sort on then by all means that is going to be the best approach -- it's precisely the reason why FirstFieldValueUpdateProcessorFactory, LastFieldValueUpdateProcessorFactory, MaxFieldValueUpdateProcessorFactory, and MinFieldValueUpdateProcessorFactory. But my interpretation of the next start time is that it wsa dependent on the value of NOW when the query was executed (ie: some of the indexed values may be in the past) in which case that approach wouldn't work. : On Tue, Dec 4, 2012, at 07:35 PM, Chris Hostetter wrote: : : : perfectly, but users expect the result set to be ordered by the next : start : : time. : ... : : Is there a more elegant way to do this in Solr? A function query or : : subquery maybe? I thought about it for quite a while and couldn't come : up : : with a viable solution. : : I think you could concievably write a custom function that built an : UnInvertedField over your multivalued field, and then returned the : lowest : value for each doc where the value is after 'NOW' but there is nothing : out of the box that will do this for you (and i haven't really thought : hard about how viable this approach is ... i can't think of any obvious : problems off the top of my head) : : -Hoss : -Hoss
Re: Sorting by multi-valued field
: (3) A third possibility I thought of was to add a field for every day of : the year to each document that contains the next-start date for that : particular day: next_start_20121212_dt etc. Then I could order by the : dynamic field. But as only some of my events are recurring and few of those : recurring over long periods of time I think it does not make too much sense. sorting on any/all of those dynamic fields is probably not going to be feasible .. .especially if the user can use a date picker to select an arbitrary field to sort on -- the memory requirments for hte FieldCache (used in sorting) are going to be huge. I would really strongly suggest you re-think your problem ... i suspect grouping is the only viable out of the box solution unless you write a custom plugin. -Hoss
Sorting by multi-valued field
Hey all! In our system users can create recurring events and search for events starting on or after a given date. Searching and filtering of events works perfectly, but users expect the result set to be ordered by the next start time. For each event, we index a multi-valued date field containing all its start times. The relevant parts of my schema look like this: - event_id - start_times_dts In SQL I would do something like: WHERE start_times = %SELECTED_DATE% GROUP BY event_id HAVING min(start_times) ORDER BY start_times ASC The only thing I could think of so far is to index every single start time of an event as a separate document and group on the event. This would solve the sorting problem but would drastically increase our index size. Is there a more elegant way to do this in Solr? A function query or subquery maybe? I thought about it for quite a while and couldn't come up with a viable solution. Cheers, Thomas
Re: Sorting by multi-valued field
: perfectly, but users expect the result set to be ordered by the next start : time. ... : Is there a more elegant way to do this in Solr? A function query or : subquery maybe? I thought about it for quite a while and couldn't come up : with a viable solution. I think you could concievably write a custom function that built an UnInvertedField over your multivalued field, and then returned the lowest value for each doc where the value is after 'NOW' but there is nothing out of the box that will do this for you (and i haven't really thought hard about how viable this approach is ... i can't think of any obvious problems off the top of my head) -Hoss
Re: Sorting by multi-valued field
But it would be a lot harder than either splitting them out into separate docs, or writing code to re-index docs when one of their 'next-event' dates passes, with a new single valued 'next-event' field. Less efficient, but easier to write/manage. Upayavira On Tue, Dec 4, 2012, at 07:35 PM, Chris Hostetter wrote: : perfectly, but users expect the result set to be ordered by the next start : time. ... : Is there a more elegant way to do this in Solr? A function query or : subquery maybe? I thought about it for quite a while and couldn't come up : with a viable solution. I think you could concievably write a custom function that built an UnInvertedField over your multivalued field, and then returned the lowest value for each doc where the value is after 'NOW' but there is nothing out of the box that will do this for you (and i haven't really thought hard about how viable this approach is ... i can't think of any obvious problems off the top of my head) -Hoss
Re: Sorting by multi-valued field
: But it would be a lot harder than either splitting them out into : separate docs, or writing code to re-index docs when one of their : 'next-event' dates passes, with a new single valued 'next-event' field. : Less efficient, but easier to write/manage. Don't get me wrong -- if you can determine at index time which single value you wnat to use to sort on then by all means that is going to be the best approach -- it's precisely the reason why FirstFieldValueUpdateProcessorFactory, LastFieldValueUpdateProcessorFactory, MaxFieldValueUpdateProcessorFactory, and MinFieldValueUpdateProcessorFactory. But my interpretation of the next start time is that it wsa dependent on the value of NOW when the query was executed (ie: some of the indexed values may be in the past) in which case that approach wouldn't work. : On Tue, Dec 4, 2012, at 07:35 PM, Chris Hostetter wrote: : : : perfectly, but users expect the result set to be ordered by the next : start : : time. : ... : : Is there a more elegant way to do this in Solr? A function query or : : subquery maybe? I thought about it for quite a while and couldn't come : up : : with a viable solution. : : I think you could concievably write a custom function that built an : UnInvertedField over your multivalued field, and then returned the : lowest : value for each doc where the value is after 'NOW' but there is nothing : out of the box that will do this for you (and i haven't really thought : hard about how viable this approach is ... i can't think of any obvious : problems off the top of my head) : : -Hoss : -Hoss