Skip to content

Commit

Permalink
Merge pull request #311 from nikcio/feat/facets
Browse files Browse the repository at this point in the history
Implementation of Facets (#310)
  • Loading branch information
Shazwazza authored Apr 13, 2023
2 parents 74d7d7f + 2a5d67b commit 711a9b3
Show file tree
Hide file tree
Showing 53 changed files with 3,335 additions and 539 deletions.
78 changes: 61 additions & 17 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,35 @@ Value types are responsible for:

These are the default field value types provided with Examine. Each value type can be resolved from the static class `Examine.FieldDefinitionTypes` (i.e. `Examine.FieldDefinitionTypes.FullText`).

| Value Type | Description | Sortable |
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
| FullText | __Default__.<br />The field will be indexed with the index's <br />default Analyzer without any sortability. <br />Generally this is fine for normal text searching. ||
| FullTextSortable | Will be indexed with FullText but also <br />enable sorting on this field for search results. <br />_FullText sortability adds additional overhead <br />since it requires an additional index field._ ||
| Integer | Stored as a numerical structure. ||
| Float | Stored as a numerical structure. ||
| Double | Stored as a numerical structure. ||
| Long | Stored as a numerical structure. ||
| DateTime | Stored as a DateTime, <br />represented by a numerical structure. ||
| DateYear | Just like DateTime but with <br />precision only to the year. ||
| DateMonth | Just like DateTime but with <br />precision only to the month. ||
| DateDay | Just like DateTime but with <br />precision only to the day. ||
| DateHour | Just like DateTime but with <br />precision only to the hour. ||
| DateMinute | Just like DateTime but with <br />precision only to the minute. ||
| EmailAddress | Uses custom analyzers for dealing <br />with email address searching. ||
| InvariantCultureIgnoreCase | Uses custom analyzers for dealing with text so it<br /> can be searched on regardless of the culture/casing. ||
| Raw | Will be indexed without analysis, searching will<br /> only match with an exact value. ||
| Value Type | Description | Sortable | Facetable |
|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|-------------|
| FullText | __Default__.<br />The field will be indexed with the index's <br />default Analyzer without any sortability. <br />Generally this is fine for normal text searching. |||
| FullTextSortable | Will be indexed with FullText but also <br />enable sorting on this field for search results. <br />_FullText sortability adds additional overhead <br />since it requires an additional index field._ |||
| Integer | Stored as a numerical structure. |||
| Float | Stored as a numerical structure. |||
| Double | Stored as a numerical structure. |||
| Long | Stored as a numerical structure. |||
| DateTime | Stored as a DateTime, <br />represented by a numerical structure. |||
| DateYear | Just like DateTime but with <br />precision only to the year. |||
| DateMonth | Just like DateTime but with <br />precision only to the month. |||
| DateDay | Just like DateTime but with <br />precision only to the day. |||
| DateHour | Just like DateTime but with <br />precision only to the hour. |||
| DateMinute | Just like DateTime but with <br />precision only to the minute. |||
| FacetFullText | The field will be indexed with the index's <br />default Analyzer without any sortability. <br />Generally this is fine for normal text searching. |||
| FacetFullTextSortable | Will be indexed with FullText but also <br />enable sorting on this field for search results. <br />_FullText sortability adds additional overhead <br />since it requires an additional index field._ |||
| FacetInteger | Stored as a numerical structure. |||
| FacetFloat | Stored as a numerical structure. |||
| FacetDouble | Stored as a numerical structure. |||
| FacetLong | Stored as a numerical structure. |||
| FacetDateTime | Stored as a DateTime, <br />represented by a numerical structure. |||
| FacetDateYear | Just like DateTime but with <br />precision only to the year. |||
| FacetDateMonth | Just like DateTime but with <br />precision only to the month. |||
| FacetDateDay | Just like DateTime but with <br />precision only to the day. |||
| FacetDateHour | Just like DateTime but with <br />precision only to the hour. |||
| FacetDateMinute | Just like DateTime but with <br />precision only to the minute. |||
| EmailAddress | Uses custom analyzers for dealing <br />with email address searching. |||
| InvariantCultureIgnoreCase | Uses custom analyzers for dealing with text so it<br /> can be searched on regardless of the culture/casing. |||
| Raw | Will be indexed without analysis, searching will<br /> only match with an exact value. |||

### Custom field value types

Expand Down Expand Up @@ -273,3 +285,35 @@ That returns an enum `ValueSetValidationResult` of values:
* `Filtered` - The ValueSet has been filtered/modified by the validator and will be indexed

Examine only has one implementation: `ValueSetValidatorDelegate` which can be used by developers as a simple way to create a validator based on a callback, else developers can implement this interface if required. By default, no ValueSet validation is done with Examine.

## Facets configuration

When using the facets feature it's possible to add facets configuration to change the behavior of the indexing.

For example, you can allow multiple values in an indexed field with the configuration below.
```csharp
// Create a config
var facetsConfig = new FacetsConfig();

// Set field to be able to contain multiple values (This is default for a field in Examine. But you only need this if you are actually using multiple values for a single field)
facetsConfig.SetMultiValued("MultiIdField", true);

services.AddExamineLuceneIndex("MyIndex",
// Set the indexing of your fields to use the facet type
fieldDefinitions: new FieldDefinitionCollection(
new FieldDefinition("Timestamp", FieldDefinitionTypes.FacetDateTime),

new FieldDefinition("MultiIdField", FieldDefinitionTypes.FacetFullText)
),
// Pass your config
facetsConfig: facetsConfig
);
```

Without this configuration for multiple values, you'll notice that your faceted search breaks or behaves differently than expected.

**Note: See more examples of how facets configuration can be used under 'Searching'**

To explore other configuration settings see the links below:
- [FacetsConfig API docs](https://lucenenet.apache.org/docs/4.8.0-beta00016/api/facet/Lucene.Net.Facet.FacetsConfig.html#methods)
- [Facets with lucene](https://norconex.com/facets-with-lucene/). See how the config is used in the code examples.
Loading

0 comments on commit 711a9b3

Please sign in to comment.