Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #113 from yuriboyko/feature/searchQuery-graphQl-Up…
Browse files Browse the repository at this point in the history
…date-1

Little update for graphql queries
  • Loading branch information
pkarw committed Sep 18, 2018
2 parents d8b3b28 + 3342636 commit c1e69bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/default.json
Expand Up @@ -9,6 +9,7 @@
"port": 9200,
"user": "elastic",
"password": "changeme",
"min_score": 0.01,
"indices": [
"vue_storefront_catalog",
"vue_storefront_catalog_de",
Expand Down
14 changes: 14 additions & 0 deletions doc/2. graphQl support.md
Expand Up @@ -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:

<config.server.host>:<config.server.port>/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:

<config.server.host>:<config.server.port>/graphiql

This tool allow to test graphql request online and show graphql server response immediatelly nad could be helpful fro development process.


## Example request

Expand Down
8 changes: 7 additions & 1 deletion src/graphql/elasticsearch/queryBuilder.js
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}

0 comments on commit c1e69bb

Please sign in to comment.