Examine Sort Order Issue
# help-with-umbraco
c
Is anyone around to help me solve an examine sort order issue please. I have got it down to a very simple example and I think sorting is broken in examine, or maybe I'm doing something wrong.
w
When I question stuff like this. I tend to clone down Shan's Examine repo
and use his tests in that project to try and write the same query as a new test to verify/confirm if its a bug or if its just me. 99% of the time its me
But quick one in the record you are looking for does it have the magic string prefix it does on the field you want sorted. Its something like __sortMyField or something similar (I can never rember syntax)
c
Thanks Warren, I followed this blog post but the magic __Sort_nodeName field isn't appearing. https://umbracare.net/blog/enable-nodename-field-sorting-in-umbraco-examine-search/
w
Hmm yeh if your record your hoping to find does not have it. If you use LUKE to browse through the index. Then suspect something going wrong in adding the new sortable field
h
sorting by Strings appears to be broken @Debasish posted about it, I tested in 13 and doesn't work either
__Sort_yourfieldname
w
Bug report on Umbraco or shans Examine repo to follow along?
c
Fixed thanks to help from Callum https://github.com/prjseal/Examine-Sorting/pull/1
w
Cool whats the TLDR version of the problem
c
TLDR was that I was using a component to do the addorupdate for the fulltextsortable field, when in fact I should have been using one of these
ConfigureIndexOptions : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
and doing it in the
Configure
method.
w
OK interesting - good to know if anyone gets caught out in the future (probably myself) 😄
c
Yeah, Deba is gonna write a blog post about it
b
Protip use postconfigure option or umbraco/examine might override your values if for some reason they load faster
d
I have written a blog on this explaining the solution and it can be found here https://www.debasish.tech/blogs/how-to-sort-on-a-string-field-in-umbraco-examine. Thank you everyone!
b
@Debasish small advice: if you using examinex / my elastic provider for examine you need specify compose after, you can avoid it by usage of https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ipostconfigureoptions-1?view=net-8.0 which I mentioned earlier, it is really annoying but I did experience issues with it (also with umbraco overriding because my compose was running too early)
d
Thanks @bielu for your feedback. Will keep that in mind
98 Views