I don’t seem to be able to get search terms highlighted in cfsearch results in the summary field. I have indexed a query and can get results but I can’t highlight them.
The attributes contexthighlightbegin and contexthighlightend are listed on the Lucee docs. In the Abode docs the terms are stated to be bold in the summary field by default. I have tried setting the attributes as bold as the highlighting doesn’t appear by default.
I created the collection on Lucee (Use the web admin/search or CFML)
<cfcollection action = "create" collection = "lexicon" path= "c">
(this created a directory ‘c’ for the index in the same directory)
I then indexed a query…
<cfquery name="getLexicon" datasource="sastra"> select le_id, le_entry, le_definition from sas_lexicon </cfquery> <cfindex query="getLexicon" collection="lexicon" action="Update" type="Custom" key="le_id" title="le_entry" body="le_definition" > <h2>Indexing Complete</h2>
Then I searched the collection using the cfsearch tag and output with coldbox html.table
<form action="" method="POST"> <cfoutput><input name="search" value="#search#"></cfoutput> <input type="submit"> </form> <cfsearch name = "mySearch" collection = "lexicon" criteria = "#search#" contexthighlightbegin="<b>" contexthighlightend="</b>" contextpassages="1" contextbytes="500" maxrows = "100"> <br/> <cfoutput> #html.table( data=mySearch, includes="key,title,summary", class="table table-striped" )# </cfoutput>
But alas no context highlighting in the summary.
Any suggestions most appreciated. Or is this simply not working in the engine?
Also why is the version of Lucene used so old? The Apache Lucene is now at 8.10. Is it worth updating Apache Lucene used by Lucee so as to support more languages?
Update: I’ve downloaded the Lucee source and found the file Lucee/core/src/main/java/lucee/runtime/tag/Search.java seems to contain the code for handling the criteria highlighting. I’m not a Java wiz but I’m interested in it. If someone might be able to cast their eye over this file it would be awesome as a functioning full text search would be so useful! It would be great to see the search term highlighted in context.
I’m wondering if there might be an issue setting the additional attributes or status.
I have found a page that lists the criteria syntax for those interested in writing search queries using cfsearch: