Comments (1)
"resolved" by setting up the models before establishing the connection to elastic search that creates the indexes.. The default indexes created are not allowed to be overridden and the default analyser is a tokeniser that strips away the "-".
import * as elasticsearch from "elasticsearch-odm-5";
const searchSchema = new elasticsearch.Schema({
thingId: { type: String },
});
const model = elasticsearch.model("things", searchSchema);
const elasticSearchCRUD = async (thingId) => {
console.log("\nCreating thing with thingId: ", thingId);
await model.create({ thingId });
await new Promise(res => setTimeout(res, 1000));
let thing = await model.findOne({ thingId });
console.log(thing);
}
const isWorking = async () => elasticSearchCRUD("a");
const notWorking = async () => elasticSearchCRUD("a-27");
const run = async () => {
await elasticsearch.connect({
host: "http://localhost:9200",
index: "my-index",
logging: true,
});
await isWorking();
await notWorking();
}
run();
$ ts-node src/test.ts
Creating thing with thingId: a
modelInstance {
thingId: 'a',
createdOn: '2018-09-04T15:56:33.169Z',
updatedOn: '2018-09-04T15:56:33.188Z',
id: 'AWWlTLgauOXlND3DZB0-' }
Creating thing with thingId: a-27
modelInstance {
thingId: 'a-27',
createdOn: '2018-09-04T15:56:34.445Z',
updatedOn: '2018-09-04T15:56:34.467Z',
id: 'AWWlTL0YuOXlND3DZB0_' }
from elasticsearch-odm.
Related Issues (19)
- Paged results aren't wrapped in PageResponse when no results exist.
- How this elasticsearch-odm combine to sailsJs ?
- Connect example fails with "TypeError: ConnectionError is not a function" HOT 3
- Validator doesn't respect double type values that don't have a decimal
- .connect returning 400 if the index doesn't exists HOT 4
- Boolean false fails to validate when required is true
- Calls to connect() when no index exists hangs on first start.
- Elasticsearch 5.4 HOT 5
- Problem with 'text' & 'keyword'
- Simple find() Query not working! HOT 1
- Basic example not working HOT 1
- child/parent relationships
- typescript support
- when page=1 & per_page=1 10 results are returned instead of 1
- Check compatibility with 2.0 HOT 2
- this is more of a question than a bug
- is the index type should be pluralize?
- Range query HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-odm.