diff --git a/README.md b/README.md index e2278e1..2bda8a8 100644 --- a/README.md +++ b/README.md @@ -67,14 +67,6 @@ $ curl -i -X POST -H 'Content-Type: application/ld+json' -H 'Link: { - console.log(`querying ElasticSearch for "${query}" (full-text search)`) - - const result = await client.search({ - index: config.get('resourceIndexName'), - type: config.get('indexType'), - body: { - query: { - multi_match: { - query: query, - fields: Object.keys(config.get('indexFieldMappings')) - } - } - } - }) - - console.dir(result.hits) -} - -const suggestSearch = async () => { - console.log(`querying ElasticSearch for "${query}" (suggest search)`) - - const suggestBody = { text: query } - - for (const [fieldName, fieldProperties] of Object.entries(config.get('indexFieldMappings'))) { - if (!fieldProperties.autosuggest) { - continue - } - - suggestBody[fieldName] = { - completion: { - field: `${fieldName}-suggest` - } - } - } - - const result = await client.search({ - index: config.get('resourceIndexName'), - type: config.get('indexType'), - body: { - suggest: suggestBody - } - }) - - console.dir(result) - console.dir(result.suggest) -} - -const runSearches = async () => { - await fullTextSearch() - await suggestSearch() -} - -runSearches() diff --git a/src/Indexer.js b/src/Indexer.js index 40c8969..bc55c72 100644 --- a/src/Indexer.js +++ b/src/Indexer.js @@ -17,7 +17,7 @@ export default class Indexer { this.knownDeleteResults = ['deleted'] this.indexers = { sinopia_templates: SinopiaTemplateIndexer, - sinopia_resources : ResourceIndexer + sinopia_resources: ResourceIndexer } } @@ -40,7 +40,7 @@ export default class Indexer { return this.client.index({ index: index, - type: 'sinopia', + type: config.get('indexType'), id: this.identifierFrom(uri), body: new indexer(json, uri).index() }).then(indexResponse => { @@ -68,7 +68,7 @@ export default class Indexer { } return this.client.delete({ index, - type: 'sinopia', + type: config.get('indexType'), id: this.identifierFrom(uri) }).then(indexResponse => { if (!this.knownDeleteResults.includes(indexResponse.result)) @@ -111,7 +111,7 @@ export default class Indexer { await this.client.indices.putMapping({ index: index, - type: 'sinopia', + type: config.get('indexType'), body: this.indexers[index].indexMapping }) }