David had an interesting question about Verity results:
Is there an easy way to order the output of a Verity spider search based on the .cfm page it offers in the results?An example:
If someone searched for "hammer". Right now my search results show Press Releases that contain "hammer" before it shows Product pages containing "hammer". Can I tell Verity to give pages such as "product.cfm" a better rank than "pressrelease.cfm" where each would have query strings?
So the short answer is - as far as I know, no. You can't tell Verity to give a higher rank based on the filename. Let me just say though that Verity's language can get super complex. I'd be willing to bet I'm wrong on this. But, either way, there is a simple way around this.
Do not forget that the result of a Verity search is a ColdFusion query. That means you can use Query of Query on it. Therefore, you could easily select all the columns, and use an order by that gives preference to another column. Now for filenames (which would be your KEY or URL value most likely), the sort would be in alphabetical order. You could assign a rank to the file type. So if the file contained product.cfm, then the rank would be 1. If it contained pressrelease.cfm, it would be 2. If you store this value in the first custom column, then you could simply sort your results like so:
ORDER BY SCORE DESC, CUSTOM1 ASC
This simply says to sort on score, but on a tie, use the CUSTOM1 column, which would contain the custom value I described above.
Archived Comments
Another technique could be to use a custom Verity field to assign a category to each item in the index, such as "Product" or "Press Release". Then when you display the search results, you can separate the records by category, making Products the default. For instance, on myStockOptions.com our search results default to "All results" but also offer tabs for separate categories.
Verity also offers the ability to create categories natively in the index and then limit a search to certain categories. Check the docs.
It also occurs to me that you could use QoQ to "split" the results into groupings by filename. In this case, you could filter first to only product pages, then to only press releases, then to everything else. Each group could be displayed individually, making it easy for someone to find which type of info they want.
But that isn't what they wanted. They didn't want to split them up - they wanted to give _priority_ to certain results. Ie, if a match in section A and B had the same score, they want B to "win".
On second reading, I guess you're right. My first reading was that they wanted <i>all</i> product pages prioritized over <i>all</i> press releases.
If I remember correctly, there is a way to give a different weight to different 'columns' of a Verity index. I'll have to look through some old code/emails to see if I can find an example.
Not sure if this will produce the desired results, though.
In the CF book "Allaire ColdFusion (Web Application Construction Kit)" by Ben Forta, Chapter 29 is a well written guide on using Verity. It gives examples of how to sort after a search with CF code examples. The Verity search language has a wide range of simple to complex commands to construct a very powerful search - but the Verity focus is search, not sort. Sorting results after a search is for CF code. ( Appendix C is a seven page guide to use the Verity search language - powerful stuff!)
Tom - In order to achive the ability to break down your search results, is that the product of multiple collections? I am stumped.
I tried adding
criteria="#form.searchtext# and <ACCRUE>([0.5](URL<CONTAINS>'product'),'#form.searchtext#')"
to my cfsearch. It worked, but with 2 side effects:
1) If you leave the search field blank, instead of prompting you to enter something, you get a parsing error
2) If you misspell a word, you get the following:
Search Results
Your search for wweb returned 0 file(s). Did you mean: web and ([0.5](URL'product'),'web')
Thanks for your patience/suggestions...
I _knew_ verity had a way of doing this.
So for the 2 issues David found:
a) You can easily fix 1 by just not doing a cfsearch on a blank search.
b) You can fix this by either not using the Suggest feature, or, and this is a bit sucky, repeating your search with a simple criteria and no accrue.
Good job, David! I should have dug deeper for sure.