This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "query": { "bool": { | |
"must": [ | |
{"term": {"description.text": "beard"}} | |
], | |
"should": [ | |
{"term": {"description":"bearded"}} | |
] | |
}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"mappings": { | |
"object": { | |
"description": { | |
"type": "text", | |
"fields": { | |
"text": { "type": "text", "analyzer": "text_description_analyzer" } | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"text_description_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ | |
"lowercase", | |
"english_stop", | |
"english_stemmer" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "query": { "bool": { "must": [ | |
{"term": {"description": "beard"}} | |
]}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elasticsearch = require('elasticsearch'); | |
const objectData; // Assume this JSON representing an object in the collection | |
const client = new elasticsearch.Client({ host: 'localhost:9200' }); | |
client.create({ | |
index: 'collection', | |
type: 'object', | |
id: objectData.id, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table collection( | |
id bigint unsigned primary key, | |
name varchar(100), | |
description varchar(512) | |
); | |
insert into collection (id, name, description) values | |
(1, 'Two Geese', 'A painting of two beautiful geese'), | |
(2, 'Roses in Bloom', 'Blooming roses, obviously'), | |
(3, 'Still Life with Cake', 'A partially eaten cake, next to a vase.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table collection( | |
id bigint unsignet primary key, | |
name varchar(100), | |
description varchar(512) | |
); | |
insert into collection (id, name, description) values | |
(1, 'Two Geese', 'A painting of two beautiful geese'), | |
(2, 'Roses in Bloom', 'Blooming roses, obviously'), | |
(3, 'Still Life with Cake', 'A partially eaten cake, next to a vase.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const logger = require('./logger.js'); | |
const fs = require('fs'); | |
const csv = require('fast-csv'); | |
module.exports = class CSVWriter { | |
constructor(path) { | |
logger.info(`Opening CSV file at ${path}`); | |
this._path = path; | |
this._csvStream = csv.createWriteStream({ headers: true }); | |
this._writableStream = fs.createWriteStream(path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from src/tms_csv/src/script/tmsURLReader.js | |
_urlForObjectWithId(id) { | |
const requestURL = url.parse(this.rootURL); | |
requestURL.pathname = `objects/${id}/json`; | |
this._addCredentialsToURL(requestURL); | |
return url.format(requestURL); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_fetchArtObjectWithId(id) { | |
const requestURLString = this._urlForObjectWithId(id); | |
logger.info(`Fething collection object with id: ${id} at url: ${requestURLString}`); | |
return new Promise((resolve, reject) => { | |
const req = https.request(requestURLString, (res) => { | |
let data = ''; | |
res.on('data', (d) => { |