Make it easier to use Examine in Umbraco

1,188 views
Skip to first unread message

Richard Soeteman

unread,
Jun 22, 2012, 4:09:55 AM6/22/12
to umbra...@googlegroups.com
Most developers that I know don't use Examine I think it's because of the configuration options.How can we integrate Examine into Umbraco in a way it's just as easy to use as XSLT search is. With XSLT search every developer can setup search in a few minutes, that's currently not the case with examine.

hor...@gmail.com

unread,
Jun 22, 2012, 4:39:18 AM6/22/12
to umbra...@googlegroups.com
+1, would definitely use Examine for searches, if was as easy to use and install as XSLTsearch...

Craig Stevens

unread,
Jun 22, 2012, 4:48:08 AM6/22/12
to umbra...@googlegroups.com
On 22/06/12 09:39, hor...@gmail.com wrote:
> +1, would definitely use Examine for searches, if was as easy to use and install as XSLTsearch...
+1 me too.

Laurence Gillian

unread,
Jun 22, 2012, 5:08:45 AM6/22/12
to umbra...@googlegroups.com
I am a big fan of Examine. But for spitting out content (results), it's a far easier syntax to query Lucene directly.

For example, if you give Lucene the search string of 'hello', it will get back all results with hello, in the fields you query. You can then also pass in search tied against the doctypealias. You can also pass in wildcards, etc.

We wrote a very simple plugin to replace XSLT search, the pulls the Lucene results back as XML, and then uses a simple apply-templates to style it all up.

e.g. tag:Umbraco -> gets all results tagged with Umbraco.

Dan Diplo

unread,
Jun 22, 2012, 5:20:24 AM6/22/12
to umbra...@googlegroups.com
I ended up writing my own Examine search classes that made it up much easier to work with. I then backed this up with a Razor front-end. I'd love to make these available but as they were created for my company I can't open-source them as I don't own them :(

What I can say is that there are a number of problems to overcome:
  1. Finding examples of the configuration file formats for creating a custom index (last time I checked these weren't part of Umbraco documentation)
  2. The Examine fluent-API just didn't cut it from writing powerful queries and ended up creating wrappers for writing out queries in Lucene Query Language directly. This isn't easy, but is the only way to access more powerful features like using proper term modifiers for fuzzy matching.
  3. You need to escape or remove a lot of special characters from search queries that can easily break it
  4. I wanted to do stuff like only search starting from a given node (which requires using the path and wildcards) and return results between dates (particularly tricky!)
  5. You need to find a way of paginating results (I wrote Razor @helper classes for this)
  6. I had to integrate the lucene highlighter to highlight matches - again not simple
  7. The versions of Lucene.net and Examine bundled with Umbraco are well behind the latest versions. I ended up downloading the latest versions to use, but this is always risky. The newer versions also create indexes not compatible with older versions, so you need to know to delete all the old indexes first.
I can show an example of how I use it:

var searchProvider = ExamineManager.Instance.SearchProviderCollection["WebSearcher"];

var fields = new ExamineSearchFields();
fields.Add(new Field("nodeName"), new TermModifier("^3~0.8"));
fields.Add(new Field("heading"), new TermModifier("^2~0.8"));
fields.Add(new Field("bodyText"), new TermModifier("~0.8"));

ExamineSearcher searcher = new ExamineSearcher(fields, searchProvider);
searcher.StartNodeId = startNode;

searcher.AliasesToIgnore = new string[] { "Slider", "SiteSettings", "SystemPage", "Redirect"  };
searcher.DateRangeToSearch = DateRange.FromQueryStringValue(dateRange);

var results = searcher.Search(searchTerm);
var pagedResults = new PagedExamineSearchResults(results, pageSize, page);

@foreach (var result in pagedResults.CurrentLuceneResultsSet)
{
 ////
}

Dan

Shannon Deminick

unread,
Jun 22, 2012, 10:23:55 AM6/22/12
to umbra...@googlegroups.com
The Examine fluent api was created a long long long time ago and I also don't like it so you can blast it as much as you like :)

I started creating an Examine v2 which was going to be used in v5 which simplifies indexing and searching a bit but the plan was to make it much nicer to use and less config. I however don't have a ton of time at the moment to make this happen. @Dan, that search syntax you've shown looks promising, wouldn't be too difficult to mimic something like this for the Examine core moving forward.

For the time being however, i don't think it would be very difficult to ship Umbraco with a default public search index configuration which indexes all published content and fields and have a Razor macro that you modify in terms of variables/parameters (just like XSLT search)... Again though, i don't really have much time at the moment to make this. 

I'll talk to Lee about at least having a default public search index specified in config for 4.8.

Shan

Richard Soeteman

unread,
Jun 22, 2012, 4:27:23 PM6/22/12
to umbra...@googlegroups.com
Nice i think a pre configured search for published content will help

Darren Ferguson

unread,
Jun 25, 2012, 5:23:57 AM6/25/12
to umbra...@googlegroups.com
+1 default front end search Examine config - also maybe a new example razor snippet called Search.


On Friday, 22 June 2012 09:09:55 UTC+1, Richard Soeteman wrote:

sjo...@gmail.com

unread,
Jul 5, 2012, 1:14:43 AM7/5/12
to umbra...@googlegroups.com
I think it would be extremely cool if examine can be configured directly in the field settings at a documenttype, just like the mandatory checkbox works.

Niels Hartvig

unread,
Jul 5, 2012, 5:42:08 AM7/5/12
to umbra...@googlegroups.com
That would be really interesting actually. Great idea!
Reply all
Reply to author
Forward
0 new messages