Contents/search again
Today I got the sorting stuff written and tested. It's basically a bunch of nested if-then-elses, with some fancy-footwork to handle sorting on two items at once (such as volume+issue). While this sorting does include sorting by title, with XSLT we can call our own little java library containing a sort comparator, which enables us to handle e.g. sorting titles while ignoring leading articles. We'll probably sort the returns in XQuery anyway, but pass the sort key on to the XSLT so that it can decide if it needs to sort them again with a more sophisticated comparator.
I also started work on the text search, which is a more complicated business. First, we need to split up the search string into a sequence of items. Items can be:
- quoted strings (for exact matches), or
- individual words.
Each item can be preceded by
- + (must match),
- - (must not match), or
- nothing (optional match).
Each non-quoted string may contain wildcards:
- * (any char(s))
- ? (any single char)
For each item, we must generate an XQuery expression, and then we have to string them all together in an appropriate way to create a single clause.
I've done this job in a less efficient and more constrained way for the Mariage project, but this is an opportunity to create a really good mapping between Google-style search syntax and eXist search functionality. There are significant problems, of course, especially with match-highlighting, but I think we can do a reasonable job.