Skip to content

Commit

Permalink
Merge pull request #350 from bjarnef/patch-1
Browse files Browse the repository at this point in the history
Update docs about facets
  • Loading branch information
Shazwazza authored Oct 27, 2023
2 parents f2dc6e7 + bb09595 commit fc532d3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/searching.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Basic example
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.Field("Address", "Hills")
.WithFacets(facets => facets.Facet("Address")) // Get facets of the Address field
.WithFacets(facets => facets.FacetString("Address")) // Get facets of the Address field
.Execute();

var addressFacetResults = results.GetFacet("Address"); // Returns the facets for the specific field Address
Expand All @@ -279,7 +279,7 @@ Filtered value example
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.Field("Address", "Hills")
.WithFacets(facets => facets.Facet("Address", "Hills")) // Get facets of the Address field
.WithFacets(facets => facets.FacetString("Address", null, new[] { "Hills" })) // Get facets of the Address field with specific value
.Execute();

var addressFacetResults = results.GetFacet("Address"); // Returns the facets for the specific field Address
Expand All @@ -289,15 +289,15 @@ var addressFacetResults = results.GetFacet("Address"); // Returns the facets for
* Label: Hills, Value: 2 <-- As Hills was the only filtered value we will only get this facet
*/

var hillsValue = addressFacetResults.Facet("Hills"); // Gets the IFacetValue for the facet Hills
var hillsValue = addressFacetResults.FacetString("Hills"); // Gets the IFacetValue for the facet Hills
```

MaxCount example
```csharp
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.Field("Address", "Hills")
.WithFacets(facets => facets.Facet("Address")) // Get facets of the Address field
.WithFacets(facets => facets.FacetString("Address")) // Get facets of the Address field
.Execute();

var addressFacetResults = results.GetFacet("Address"); // Returns the facets for the specific field Address
Expand All @@ -311,7 +311,7 @@ var addressFacetResults = results.GetFacet("Address"); // Returns the facets for

results = searcher.CreateQuery()
.Field("Address", "Hills")
.WithFacets(facets => facets.Facet("Address", config => config.MaxCount(2))) // Get facets of the Address field & Gets the top 2 results (The facets with the highest value)
.WithFacets(facets => facets.FacetString("Address", config => config.MaxCount(2))) // Get facets of the Address field & Gets the top 2 results (The facets with the highest value)
.Execute();

addressFacetResults = results.GetFacet("Address"); // Returns the facets for the specific field Address
Expand Down Expand Up @@ -346,7 +346,7 @@ services.AddExamineLuceneIndex("MyIndex",
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.Field("Address", "Hills")
.WithFacets(facets => facets.Facet("Address")) // Get facets of the Address field from the facet field address_facet (The facet field is automatically read from the FacetsConfig)
.WithFacets(facets => facets.FacetString("Address")) // Get facets of the Address field from the facet field address_facet (The facet field is automatically read from the FacetsConfig)
.Execute();

var addressFacetResults = results.GetFacet("Address"); // Returns the facets for the specific field Address
Expand All @@ -362,14 +362,14 @@ var addressFacetResults = results.GetFacet("Address"); // Returns the facets for

Numeric range facets can be used with numbers and get facets for numeric ranges. For example, it would group documents of the same price range.

There's two categories of numeric ranges - `DoubleRanges` and `Int64Range` for double/float values and int/long/datetime values respectively.
There's three categories of numeric ranges - `DoubleRange`, `FloatRange` and `Int64Range` for double, float and int/long/datetime values respectively.

Double range example
```csharp
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.All()
.WithFacets(facets => facets.Facet("Price", new DoubleRange[] {
.WithFacets(facets => facets.FacetDoubleRange("Price", new DoubleRange[] {
new DoubleRange("0-10", 0, true, 10, true),
new DoubleRange("11-20", 11, true, 20, true)
})) // Get facets of the price field
Expand All @@ -391,7 +391,7 @@ Float range example
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.All()
.WithFacets(facets => facets.Facet("Price", new FloatRange[] {
.WithFacets(facets => facets.FacetFloatRange("Price", new FloatRange[] {
new FloatRange("0-10", 0, true, 10, true),
new FloatRange("11-20", 11, true, 20, true)
})) // Get facets of the price field
Expand All @@ -413,7 +413,7 @@ Int/Long range example
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.All()
.WithFacets(facets => facets.Facet("Price", new Int64Range[] {
.WithFacets(facets => facets.FacetLongRange("Price", new Int64Range[] {
new Int64Range("0-10", 0, true, 10, true),
new Int64Range("11-20", 11, true, 20, true)
})) // Get facets of the price field
Expand All @@ -435,7 +435,7 @@ DateTime range example
var searcher = myIndex.Searcher;
var results = searcher.CreateQuery()
.All()
.WithFacets(facets => facets.Facet("Created", new Int64Range[] {
.WithFacets(facets => facets.FacetLongRange("Created", new Int64Range[] {
new Int64Range("first", DateTime.UtcNow.AddDays(-1).Ticks, true, DateTime.UtcNow.Ticks, true),
new Int64Range("last", DateTime.UtcNow.AddDays(1).Ticks, true, DateTime.UtcNow.AddDays(2).Ticks, true)
})) // Get facets of the price field
Expand All @@ -450,4 +450,4 @@ var createdFacetResults = results.GetFacet("Created"); // Returns the facets for
*/

var firstRangeValue = createdFacetResults.Facet("first"); // Gets the IFacetValue for the facet "first"
```
```

0 comments on commit fc532d3

Please sign in to comment.