1

I am building a C# windows form application that searches a database and displaying the results. I am trying to find a guide on how to create facets with Lucene but it seems that I can't. I am creating the index and I am able to search a database but I want to create facets for the results. Is there any guide or a project to use as example?

EDIT here's the link to my project so far https://github.com/assignment128A-adopse/Assignment

any help/suggestion would be helpful

Nomik
  • 145
  • 2
  • 10

1 Answers1

6

There are a few options.

Option #1

In Lucene.Net 4.8.0, you can use the Lucene.Net.Facet module to setup faceted search. See the Lucene API documentation.

Option #2

You could use the Simple Faceted Search contrib project, but as far as I can tell, it only groups the facets for you and gets their count. I believe that if you need to actually list what matches the selected facets you have to build it yourself.

https://cwiki.apache.org/confluence/display/LUCENENET/Simple+Faceted+Search

https://github.com/apache/lucenenet/tree/812e1c541f1a00392391c5761fd3dcb7b0aedd88/src/contrib/SimpleFacetedSearch

https://github.com/apache/lucenenet/blob/3.0.3/test/contrib/SimpleFacetedSearch/TestSimpleFacetedSearch.cs

Option #3

Use BoboBrowse.Net. It is a full faceted search engine that not only works out the facet counts, but allows facets to be selected as well as retrieving the list of matches with built in sorting and paging. There are also lots of built-in facet types such as ranges and geo-location.

Note that although the demos are done in MVC, setting it up in Windows Forms is similar (easier actually because you don't need to use AJAX to reload the results when the selections change).

Option #4

Use SOLR. It is a server-based solution that runs on Java that can be set up to do faceted search.

There is also a .NET client for SOLR - (faceting documentation)

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • Thanks for you comment. I think i'm going with the BoboBrowse.Net. How exactly can i use the mvc code provided in the Demos to my windows form application. its kinda confusing. thanks for your time. – Nomik Dec 17 '15 at 13:10
  • BoboBrowse.Net is simply an object model, so it will work fundamentally the same in any UI technology. First you need to build a bobo-friendly search index as [done here](https://github.com/NightOwl888/FacetedSearchPrototype/blob/master/src/FacetedSearchPrototype/Controllers/SearchController.cs#L245). Next, you should setup the BoboIndexReader as a singleton instance in your application and dispose of it when the application closes. – NightOwl888 Dec 17 '15 at 15:27
  • You need to [setup your facets](https://github.com/NightOwl888/FacetedSearchPrototype/blob/master/src/FacetedSearchPrototype/Controllers/SearchController.cs#L378) before you open the reader (at app start or optionally you can do that [in xml](https://github.com/NightOwl888/BoboBrowse.Net/wiki/Spring.Net-XML-Configuration)). Then, you hook the selections to your UI (often checkboxes) and upon each checkbox click you should [perform a browse](https://github.com/NightOwl888/FacetedSearchPrototype/blob/master/src/FacetedSearchPrototype/Controllers/SearchController.cs#L468) to update UI results. – NightOwl888 Dec 17 '15 at 15:30
  • Thanks helped me alot! – Mad Dog Tannen Dec 06 '17 at 14:43
  • @NightOwl888 what's missing with SimpleFacetedSearch? – eyal Mar 28 '18 at 11:24
  • I put together a quick example of indexing and searching sides including facets for those that want to see some code: https://laimis.medium.com/faceted-search-with-lucene-net-1045825d3542 Documentation was a bit dense to read through and figure out how to build a quick POC. – Laimonas Simutis Apr 24 '23 at 20:52