diff --git a/config/default.json b/config/default.json index 7a2cab8a..606dcd67 100644 --- a/config/default.json +++ b/config/default.json @@ -9,6 +9,7 @@ "port": 9200, "user": "elastic", "password": "changeme", + "min_score": 0.01, "indices": [ "vue_storefront_catalog", "vue_storefront_catalog_de", diff --git a/doc/2. graphQl support.md b/doc/2. graphQl support.md index 65ea24b7..d131d133 100644 --- a/doc/2. graphQl support.md +++ b/doc/2. graphQl support.md @@ -45,6 +45,20 @@ const resolver = { For other entity types you can check schemas and resolvers in the /src/graphql/elasticsearch correspond subfolder +## GraphQl server host and test tool + +graphql server host is: + +:/graphql + +So by default it is http://localhost:8080/graphql + +Also for testing graphql requests Graphiql web tool can be used. It can be accesible by url: + +:/graphiql + +This tool allow to test graphql request online and show graphql server response immediatelly nad could be helpful fro development process. + ## Example request diff --git a/src/graphql/elasticsearch/queryBuilder.js b/src/graphql/elasticsearch/queryBuilder.js index e3ac1d4d..ce74c2f6 100644 --- a/src/graphql/elasticsearch/queryBuilder.js +++ b/src/graphql/elasticsearch/queryBuilder.js @@ -2,6 +2,7 @@ import bodybuilder from 'bodybuilder'; import getBoosts from '../../lib/boost' import map from 'lodash/map'; import getMapping from './mapping' +import config from 'config' function processNestedFieldFilter(attribute, value) { let processedFilter = { @@ -171,5 +172,10 @@ export function buildQuery({ query = query.from((currentPage - 1) * pageSize).size(pageSize); - return query.build(); + let builtQuery = query.build() + if (search != '') { + builtQuery['min_score'] = config.elasticsearch.min_score + } + + return builtQuery; }