Re: Sorting fields with letters?
Tried using the ord() function, but it was the same as the standard sort. Do I just need to bite the bullet and reindex everything? Thanks! Pete On Oct 21, 2011, at 5:26 PM, Tomás Fernández Löbbe wrote: I don't know if you'll find exactly what you need, but you can sort by any field or FunctionQuery. See http://wiki.apache.org/solr/FunctionQuery On Fri, Oct 21, 2011 at 7:03 PM, Peter Spam ps...@mac.com wrote: Is there a way to use a custom sorter, to avoid re-indexing? Thanks! Pete On Oct 21, 2011, at 2:13 PM, Tomás Fernández Löbbe wrote: Well, yes. You probably have a string field for that content, right? so the content is being compared as strings, not as numbers, that why something like 1000 is lower than 2. Leading zeros would be an option. Another option is to separate the field into numeric fields and sort by those (this last option is only recommended if your data always look similar). Something like 11C15 to field1: 11, field2:C field3: 15. Then use sort=field1,field2,field3. Anyway, both this options require reindexing. Regards, Tomás On Fri, Oct 21, 2011 at 4:57 PM, Peter Spam ps...@mac.com wrote: Hi everyone, I have a field that has a letter in it (for example, 1A1, 2A1, 11C15, etc.). Sorting it seems to work most of the time, except for a few things, like 10A1 is lower than 8A100, and 10A100 is lower than 10A99. Any ideas? I bet if my data had leading zeros (ie 10A099), it would behave better? (But I can't really change my data now, as it would take a few days to re-inject - which is possible but a hassle). Thanks! Pete
Sorting fields with letters?
Hi everyone, I have a field that has a letter in it (for example, 1A1, 2A1, 11C15, etc.). Sorting it seems to work most of the time, except for a few things, like 10A1 is lower than 8A100, and 10A100 is lower than 10A99. Any ideas? I bet if my data had leading zeros (ie 10A099), it would behave better? (But I can't really change my data now, as it would take a few days to re-inject - which is possible but a hassle). Thanks! Pete
Re: Sorting fields with letters?
Well, yes. You probably have a string field for that content, right? so the content is being compared as strings, not as numbers, that why something like 1000 is lower than 2. Leading zeros would be an option. Another option is to separate the field into numeric fields and sort by those (this last option is only recommended if your data always look similar). Something like 11C15 to field1: 11, field2:C field3: 15. Then use sort=field1,field2,field3. Anyway, both this options require reindexing. Regards, Tomás On Fri, Oct 21, 2011 at 4:57 PM, Peter Spam ps...@mac.com wrote: Hi everyone, I have a field that has a letter in it (for example, 1A1, 2A1, 11C15, etc.). Sorting it seems to work most of the time, except for a few things, like 10A1 is lower than 8A100, and 10A100 is lower than 10A99. Any ideas? I bet if my data had leading zeros (ie 10A099), it would behave better? (But I can't really change my data now, as it would take a few days to re-inject - which is possible but a hassle). Thanks! Pete
Re: Sorting fields with letters?
Is there a way to use a custom sorter, to avoid re-indexing? Thanks! Pete On Oct 21, 2011, at 2:13 PM, Tomás Fernández Löbbe wrote: Well, yes. You probably have a string field for that content, right? so the content is being compared as strings, not as numbers, that why something like 1000 is lower than 2. Leading zeros would be an option. Another option is to separate the field into numeric fields and sort by those (this last option is only recommended if your data always look similar). Something like 11C15 to field1: 11, field2:C field3: 15. Then use sort=field1,field2,field3. Anyway, both this options require reindexing. Regards, Tomás On Fri, Oct 21, 2011 at 4:57 PM, Peter Spam ps...@mac.com wrote: Hi everyone, I have a field that has a letter in it (for example, 1A1, 2A1, 11C15, etc.). Sorting it seems to work most of the time, except for a few things, like 10A1 is lower than 8A100, and 10A100 is lower than 10A99. Any ideas? I bet if my data had leading zeros (ie 10A099), it would behave better? (But I can't really change my data now, as it would take a few days to re-inject - which is possible but a hassle). Thanks! Pete
Re: Sorting fields with letters?
I don't know if you'll find exactly what you need, but you can sort by any field or FunctionQuery. See http://wiki.apache.org/solr/FunctionQuery On Fri, Oct 21, 2011 at 7:03 PM, Peter Spam ps...@mac.com wrote: Is there a way to use a custom sorter, to avoid re-indexing? Thanks! Pete On Oct 21, 2011, at 2:13 PM, Tomás Fernández Löbbe wrote: Well, yes. You probably have a string field for that content, right? so the content is being compared as strings, not as numbers, that why something like 1000 is lower than 2. Leading zeros would be an option. Another option is to separate the field into numeric fields and sort by those (this last option is only recommended if your data always look similar). Something like 11C15 to field1: 11, field2:C field3: 15. Then use sort=field1,field2,field3. Anyway, both this options require reindexing. Regards, Tomás On Fri, Oct 21, 2011 at 4:57 PM, Peter Spam ps...@mac.com wrote: Hi everyone, I have a field that has a letter in it (for example, 1A1, 2A1, 11C15, etc.). Sorting it seems to work most of the time, except for a few things, like 10A1 is lower than 8A100, and 10A100 is lower than 10A99. Any ideas? I bet if my data had leading zeros (ie 10A099), it would behave better? (But I can't really change my data now, as it would take a few days to re-inject - which is possible but a hassle). Thanks! Pete