You've already forked multi-select-facet
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:
5
Makefile
5
Makefile
@@ -1,10 +1,11 @@
|
|||||||
|
DOCKER ?= docker
|
||||||
SOLR_INST ?="solr-multi-select-facet-demo"
|
SOLR_INST ?="solr-multi-select-facet-demo"
|
||||||
COLLECTION ?= "multi-select-facet-demo"
|
COLLECTION ?= "multi-select-facet-demo"
|
||||||
|
|
||||||
.PHONY: solr
|
.PHONY: solr
|
||||||
solr: stop-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
|
.PHONY: stop-solr
|
||||||
stop-solr:
|
stop-solr:
|
||||||
docker rm -f $(SOLR_INST) || true
|
$(DOCKER) rm -f $(SOLR_INST) || true
|
||||||
14
README.md
14
README.md
@@ -7,12 +7,21 @@ Blog post: [Multi-Select Facet with Solr, Vue and Go](https://sf9v.github.io/pos
|
|||||||
|
|
||||||
## Running the example
|
## Running the example
|
||||||
|
|
||||||
1. Run Solr in docker.
|
1. Run Solr in `docker`.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ make solr
|
$ 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
|
2. Run the API
|
||||||
```console
|
```console
|
||||||
@@ -41,7 +50,6 @@ $ yarn serve // or npm run serve
|
|||||||
4. Open http://localhost:8080 in your browser and start playing with it!
|
4. Open http://localhost:8080 in your browser and start playing with it!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## 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).
|
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).
|
||||||
|
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initSolrSchema(ctx context.Context, collection string, solrClient solr.Client) (err error) {
|
func initSolrSchema(ctx context.Context, collection string, solrClient solr.Client) (err error) {
|
||||||
|
|
||||||
// auto-suggest field type
|
// auto-suggest field type
|
||||||
fieldTypes := []solrschema.FieldType{
|
fieldTypes := []solrschema.FieldType{
|
||||||
|
|
||||||
// // approach #1
|
// // approach #1
|
||||||
// // see: https://blog.griddynamics.com/implementing-autocomplete-with-solr/
|
// // 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
|
// approach #2
|
||||||
// see: https://blog.griddynamics.com/implement-autocomplete-search-for-large-e-commerce-catalogs/
|
// see: https://blog.griddynamics.com/implement-autocomplete-search-for-large-e-commerce-catalogs/
|
||||||
{
|
{
|
||||||
Name: "text_suggest",
|
Name: "text_suggest",
|
||||||
Class: "solr.TextField",
|
Class: "solr.TextField",
|
||||||
Stored: true,
|
PositionIncrementGap: "100",
|
||||||
IndexAnalyzer: &solrschema.Analyzer{
|
IndexAnalyzer: &solrschema.Analyzer{
|
||||||
Tokenizer: &solrschema.Tokenizer{
|
Tokenizer: &solrschema.Tokenizer{
|
||||||
Class: "solr.WhitespaceTokenizerFactory",
|
Class: "solr.WhitespaceTokenizerFactory",
|
||||||
@@ -150,6 +150,11 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
|
|||||||
{
|
{
|
||||||
Class: "solr.ASCIIFoldingFilterFactory",
|
Class: "solr.ASCIIFoldingFilterFactory",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Class: "solr.EdgeNGramFilterFactory",
|
||||||
|
MinGramSize: 1,
|
||||||
|
MaxGramSize: 20,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
QueryAnalyzer: &solrschema.Analyzer{
|
QueryAnalyzer: &solrschema.Analyzer{
|
||||||
@@ -182,39 +187,29 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
|
|||||||
// define the fields
|
// define the fields
|
||||||
fields := []solrschema.Field{
|
fields := []solrschema.Field{
|
||||||
{
|
{
|
||||||
Name: "docType",
|
Name: "docType",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Indexed: true,
|
|
||||||
Stored: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Type: "text_general",
|
Type: "text_general",
|
||||||
Indexed: true,
|
|
||||||
Stored: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "category",
|
Name: "category",
|
||||||
Type: "text_gen_sort",
|
Type: "text_gen_sort",
|
||||||
Indexed: true,
|
|
||||||
Stored: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "brand",
|
Name: "brand",
|
||||||
Type: "text_gen_sort",
|
Type: "text_gen_sort",
|
||||||
Indexed: true,
|
|
||||||
Stored: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "productType",
|
Name: "productType",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
Indexed: true,
|
|
||||||
Stored: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "suggest",
|
Name: "suggest",
|
||||||
Type: "text_suggest",
|
Type: "text_suggest",
|
||||||
Stored: true,
|
Stored: false,
|
||||||
MultiValued: true,
|
MultiValued: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -231,22 +226,6 @@ func initSolrSchema(ctx context.Context, collection string, solrClient solr.Clie
|
|||||||
Source: "name",
|
Source: "name",
|
||||||
Dest: "suggest",
|
Dest: "suggest",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Source: "category",
|
|
||||||
Dest: "suggest",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Source: "brand",
|
|
||||||
Dest: "suggest",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Source: "productType",
|
|
||||||
Dest: "suggest",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Source: "*_s",
|
|
||||||
Dest: "suggest",
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Source: "name",
|
Source: "name",
|
||||||
@@ -288,7 +267,7 @@ func initSuggestConfig(ctx context.Context, collection string, configClient solr
|
|||||||
"class": "solr.SuggestComponent",
|
"class": "solr.SuggestComponent",
|
||||||
"suggester": Map{
|
"suggester": Map{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"lookupImpl": "FuzzyLookupFactory",
|
"lookupImpl": "AnalyzingInfixLookupFactory",
|
||||||
"dictionaryImpl": "DocumentDictionaryFactory",
|
"dictionaryImpl": "DocumentDictionaryFactory",
|
||||||
"field": "suggest",
|
"field": "suggest",
|
||||||
"suggestAnalyzerFieldType": "text_suggest",
|
"suggestAnalyzerFieldType": "text_suggest",
|
||||||
|
|||||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 85 KiB |
@@ -13,7 +13,7 @@
|
|||||||
clearable
|
clearable
|
||||||
>
|
>
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
{{ props.option.term }}
|
<span v-html="props.option.term"></span>
|
||||||
</template>
|
</template>
|
||||||
</b-autocomplete>
|
</b-autocomplete>
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|||||||
Reference in New Issue
Block a user