You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 1, 2024. It is now read-only.
@@ -18,6 +22,82 @@ To [install from NuGet](https://www.nuget.org/packages/Examine.Facets/), run the
18
22
19
23
PM> Install-Package Examine.Facets
20
24
25
+
## Usage
26
+
27
+
Examine Facets integrates seamlessly with the Examine API. *Read the [Examine docs](https://shazwazza.github.io/Examine/) first.*
28
+
29
+
### Register the searcher
30
+
31
+
There are 2 facet engines available out of the box: [Bobo Browse](https://www.nuget.org/packages/Examine.Facets.BoboBrowse/) and [Multi Facets](https://www.nuget.org/packages/Examine.Facets.MultiFacets/). Both offer a similar choice of features and performance so it is really a matter of preference.
32
+
33
+
To perform facet queries the chosen facet engine's Searcher must be registered via `ExamineManager`. This requires only a few lines of configuration code.
34
+
35
+
For example the [Bobo Browse](https://www.nuget.org/packages/Examine.Facets.BoboBrowse/) Searcher can be registered like this:
36
+
37
+
```
38
+
if (_examineManager.TryGetIndex("CustomIndex", out IIndex index))
39
+
{
40
+
if (index is LuceneIndex luceneIndex)
41
+
{
42
+
var searcher = new BoboFacetSearcher(
43
+
"FacetSearcher",
44
+
luceneIndex.GetIndexWriter(),
45
+
luceneIndex.DefaultAnalyzer,
46
+
luceneIndex.FieldValueTypeCollection
47
+
);
48
+
49
+
_examineManager.AddSearcher(searcher);
50
+
}
51
+
}
52
+
```
53
+
54
+
### Querying
55
+
56
+
Defining and querying facets is baked right into Examine's fluent API.
57
+
58
+
Begin a facet query by calling `.Facet(string field)` within a query, or filter results to a facet with a specific value by calling `.Facet(string field, string[] values)`.
59
+
60
+
Further optional configuration – such as the minimum number of matches required for a facet to appear, or the maximum number of values to return – can also be configured configured through the fluent API.
61
+
62
+
```
63
+
_examineManager.TryGetSearcher("FacetSearcher", out ISearcher searcher);
64
+
65
+
var query = searcher.CreateQuery();
66
+
67
+
query.And()
68
+
.Facet("CustomField")
69
+
.MinHits(10)
70
+
.MaxCount(100);
71
+
```
72
+
73
+
### Results
74
+
75
+
Facet searches behave the same as any other Examine search. To retreive information about facets there are some handy extension methods.
76
+
77
+
```
78
+
var results = searcher.Execute();
79
+
```
80
+
81
+
To get a list of all facets:
82
+
83
+
```
84
+
results.GetFacets();
85
+
```
86
+
87
+
To get a list of values for a specific facet:
88
+
89
+
```
90
+
results.GetFacet(string field);
91
+
```
92
+
93
+
To get the number of hits for a specific value:
94
+
95
+
```
96
+
results
97
+
.GetFacet(string field)
98
+
.GetHits(object value);
99
+
```
100
+
21
101
## Contribution guidelines
22
102
23
103
To raise a new bug, create an issue on the GitHub repository. To fix a bug or add new features, fork the repository and send a pull request with your changes. Feel free to add ideas to the repository's issues list if you would to discuss anything related to the library.
@@ -26,6 +106,14 @@ To raise a new bug, create an issue on the GitHub repository. To fix a bug or ad
26
106
27
107
This project is maintained by [Callum Whyte](https://callumwhyte.com/) and contributors. If you have any questions about the project please get in touch on [Twitter](https://twitter.com/callumbwhyte), or by raising an issue on GitHub.
28
108
109
+
## Credits
110
+
111
+
[Examine](https://github.com/shazwazza/examine) was created by [Shannon Deminick](https://github.com/shazwazza) and is licensed under [Microsoft Public License (MS-PL)](https://opensource.org/licenses/ms-pl).
112
+
113
+
[BoboBrowse.Net](https://github.com/NightOwl888/BoboBrowse.Net) was created by [Shad Storhaug](https://github.com/NightOwl888) and is licensed under [Apache License 2.0](https://github.com/NightOwl888/BoboBrowse.Net/blob/master/LICENSE.md).
114
+
115
+
[MultiFacetLucene.Net](https://github.com/aspcodenet/MultiFacetLuceneNet) was created by [Stefan Holmberg](https://github.com/aspcodenet).
0 commit comments