1
0
mirror of https://github.com/stevenferrer/multi-select-facet.git synced 2025-11-23 21:54:45 +02:00

suggest highlight

This commit is contained in:
Steven Ferrer
2020-10-19 18:35:21 +08:00
parent 4b8965cd3e
commit 4ecfae2bf4
5 changed files with 36 additions and 48 deletions

View File

@@ -1,10 +1,11 @@
DOCKER ?= docker
SOLR_INST ?="solr-multi-select-facet-demo"
COLLECTION ?= "multi-select-facet-demo"
.PHONY: solr
solr: stop-solr
docker run -d -p 8983:8983 --name $(SOLR_INST) solr:latest solr-precreate $(COLLECTION)
$(DOCKER) run -d -p 8983:8983 --name $(SOLR_INST) solr:latest solr-precreate $(COLLECTION)
.PHONY: stop-solr
stop-solr:
docker rm -f $(SOLR_INST) || true
$(DOCKER) rm -f $(SOLR_INST) || true

View File

@@ -7,12 +7,21 @@ Blog post: [Multi-Select Facet with Solr, Vue and Go](https://sf9v.github.io/pos
## Running the example
1. Run Solr in docker.
1. Run Solr in `docker`.
```console
$ make solr
```
Wait for a few seconds while Solr is loading.
Or using [podman](https://podman.io/).
```console
$ DOCKER=podman make solr
```
The above commands starts Solr container and pre-creates `multi-select-facet-demo` collection.
Wait for a few seconds until Solr has completed loading.
2. Run the API
```console
@@ -41,7 +50,6 @@ $ yarn serve // or npm run serve
4. Open http://localhost:8080 in your browser and start playing with it!
## Contributing
Please feel free to improve this by [sending a PR](https://github.com/sf9v/multi-select-facet/pulls) or [opening an issue](https://github.com/sf9v/multi-select-facet/issues).

View File

@@ -97,9 +97,9 @@ func main() {
}
func initSolrSchema(ctx context.Context, collection string, solrClient solr.Client) (err error) {
// auto-suggest field type
fieldTypes := []solrschema.FieldType{
// // approach #1
// // see: https://blog.griddynamics.com/implementing-autocomplete-with-solr/
// {
@@ -136,9 +136,9 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
// approach #2
// see: https://blog.griddynamics.com/implement-autocomplete-search-for-large-e-commerce-catalogs/
{
Name: "text_suggest",
Class: "solr.TextField",
Stored: true,
Name: "text_suggest",
Class: "solr.TextField",
PositionIncrementGap: "100",
IndexAnalyzer: &solrschema.Analyzer{
Tokenizer: &solrschema.Tokenizer{
Class: "solr.WhitespaceTokenizerFactory",
@@ -150,6 +150,11 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
{
Class: "solr.ASCIIFoldingFilterFactory",
},
{
Class: "solr.EdgeNGramFilterFactory",
MinGramSize: 1,
MaxGramSize: 20,
},
},
},
QueryAnalyzer: &solrschema.Analyzer{
@@ -182,39 +187,29 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
// define the fields
fields := []solrschema.Field{
{
Name: "docType",
Type: "string",
Indexed: true,
Stored: true,
Name: "docType",
Type: "string",
},
{
Name: "name",
Type: "text_general",
Indexed: true,
Stored: true,
Name: "name",
Type: "text_general",
},
{
Name: "category",
Type: "text_gen_sort",
Indexed: true,
Stored: true,
Name: "category",
Type: "text_gen_sort",
},
{
Name: "brand",
Type: "text_gen_sort",
Indexed: true,
Stored: true,
Name: "brand",
Type: "text_gen_sort",
},
{
Name: "productType",
Type: "string",
Indexed: true,
Stored: true,
Name: "productType",
Type: "string",
},
{
Name: "suggest",
Type: "text_suggest",
Stored: true,
Stored: false,
MultiValued: true,
},
}
@@ -231,22 +226,6 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
Source: "name",
Dest: "suggest",
},
{
Source: "category",
Dest: "suggest",
},
{
Source: "brand",
Dest: "suggest",
},
{
Source: "productType",
Dest: "suggest",
},
{
Source: "*_s",
Dest: "suggest",
},
{
Source: "name",
@@ -288,7 +267,7 @@ func initSuggestConfig(ctx context.Context, collection string, configClient solr
"class": "solr.SuggestComponent",
"suggester": Map{
"name": "default",
"lookupImpl": "FuzzyLookupFactory",
"lookupImpl": "AnalyzingInfixLookupFactory",
"dictionaryImpl": "DocumentDictionaryFactory",
"field": "suggest",
"suggestAnalyzerFieldType": "text_suggest",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 85 KiB

View File

@@ -13,7 +13,7 @@
clearable
>
<template slot-scope="props">
{{ props.option.term }}
<span v-html="props.option.term"></span>
</template>
</b-autocomplete>
</b-field>