Comments (23)
Also seeing this with latest ES 5.4 and mongoosastic 4.3.0. Just seems to igonre it, and digging into the source, I don't see where this would've ever worked.
from mongoosastic.
This is part of my working schema. With analized and not_analized indexed data.
MessageSchema = new mongoose.Schema({
ts: {type: Date, default: Date.now, required: true},
details: {
title: {type: String, trim: true, match: /\S+/, required: true, es_indexed: true },
},
scope: {
nbhd: {
city: {type: String, trim: true, es_indexed: true, es_index: 'not_analyzed'},
zipCode: {type: String, trim: true, es_indexed: true, es_index: 'not_analyzed'},
}
}
}, {versionKey: false});
MessageSchema.plugin(mongoosastic);
var model = mongoose.model('Message', MessageSchema);
from mongoosastic.
All Elasticsearch properties must be prefixed with "es_". Try changing index: 'not_analyzed'
to es_index: 'not_analyzed'
from mongoosastic.
@guumaster i also have been using like what you mention, but it not working.
from mongoosastic.
@Aredo I'm currently using this feature and works properly after adding es_index: 'not_analyzed'
. Try recreating the index and check your elasticsearch.
from mongoosastic.
@guumaster Thanks for your answer. I tried your suggestion but it's not working for me. The parameter is still not recognized by Elasticsearch, even after completely erasing the index and recreating it.
@Aredo So, you are facing the same problem? Are you also manually entering the index to make it work or do you have another workaround?
from mongoosastic.
@guumaster Do you have an idea of where else I should try to look to fix that problem?
from mongoosastic.
I've created a simple test and was able to reproduce this problem. It seems that we need to check the "magic" behind mapping-generator.js
and see why sometimes it doens't work as expected.
from mongoosastic.
I am also facing the same problem, I've tried both index: 'not_analyzed' and es_index: 'not_analyzed' , but still its not working.
from mongoosastic.
I'm using it and it works, but it seems in some cases it doesn't. In my working example, I assure you that the correct name is es_index
.
We have to compare and figure out why sometimes it doesn't add the not_analyzed
property.
from mongoosastic.
@guumaster can you past to us how you define your Schema when using mongoosastic
from mongoosastic.
Greeting,
I am having a similar issue. Perhaps my mapping is incorrect. I am trying to index an array field with not_analyzed. I followed this example: https://www.elastic.co/guide/en/elasticsearch/guide/current/aggregations-and-analysis.html
The mapping of the field instStat after indexing is as follow:
"instStat": {
"type": "string"
}
This should not be the case. It is analyzing and breaking up words. I want it to aggregate by the entire phrase. How can I get around this?
Here is the schema:
var UserSchema = new Schema({
email: String,
acadPlan: [],
institutionCount: Number,
courseCount: Number,
lastPage: String,
instStat: {type: String,
es_type: 'multi_field',
es_fields : {
name : { es_type: 'string', es_index: 'not_analyzed'}
}
},
created: { type: Date, default: Date.now }
});
UserSchema.plugin(mongoosastic, {
index : 'transfer',
type : 'users'
});
var User = mongoose.model('User', UserSchema, 'users');
from mongoosastic.
I was also facing this problem but finally I got a work around for it. You can add 'not_analyzed' in mongosastic library.
ex.
go node_modules->mongoosastic->lib->mapping-generator.js
In a function getCleanTree
find and replace this code
else if (value === String || value === Object || value === Date || value === Number || value === Boolean || value === Array) {
cleanTree[field] = {};
cleanTree[field].type = type;
if (cleanTree[field].type === 'string') {
cleanTree[field].fields = {
raw: {
type: 'string',
index: 'not_analyzed'
}
};
}
}
from mongoosastic.
I managed to get it working by calling createMapping after the schema definition. I don't know if this should be required or not, I can't figure it out from the docs.
from mongoosastic.
I've got the same issue, and tried to work around it the same way that @francesconero did: By calling createMapping
after schema definition. I'm getting
[Error: [index_already_exists_exception] already exists, with { index=books }]
there though.
from mongoosastic.
Is it possible since ES 2.2 the multi_field
in Mongoosastic doesn't work anymore due to this breaking change? https://www.elastic.co/guide/en/elasticsearch/reference/current/_multi_fields.html
from mongoosastic.
Thanks guumaster, worked for me. I am also calling createMapping after schema definition by the way.
from mongoosastic.
I seem to be getting this issue to even after calling createMapping. Does anyone have a full working code sample that I could take a look at?
from mongoosastic.
I used lang:{type:String,es_indexed:true,es_index:'not_analyzed'}, if you previously created the index without not_analyzed, delete the index using curl -XDELETE 'http://localhost:9200/indexname/'
from mongoosastic.
Why is 'not analyzed' necessary? According to the documentation:
specifying es_indexed: true
:
In this case only the name field will be indexed for searching.
Also, you guys are saying to use es_index
but the npm docs is saying es_indexed
, which is it?
from mongoosastic.
@danielmeng07 es_indexed
seems to be correct, not es_index
.
from mongoosastic.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from mongoosastic.
Closing this issue due to lack of activity. Thank you for your contributions.
from mongoosastic.
Related Issues (20)
- Can't get nested fields. HOT 2
- Dependency Dashboard
- v5.0 Roadmap HOT 17
- Publish new major version to NPM HOT 1
- Unable to es_index values inside discriminator's schemas HOT 2
- Add option to overwrite the default ignore_above mapping value of 256 characters HOT 2
- update `jest` to latest version HOT 2
- synchronize function not working as expected HOT 3
- Improve error messages on bulk request errors HOT 1
- accept string on es_schema HOT 1
- need bulkAdd method to be exposed so we can use it on the model , as we are facing problem with synchronize method HOT 7
- Unable to bulk index - Error: "[action_request_validation_exception] Validation Failed: 1: type is missing;"
- Cannot connect to elasticsearch server from docker container HOT 1
- Option `routing` is not in the documentation HOT 1
- The ElasticSearch result does not contain body - it should be just res.hits HOT 4
- --production flag issue
- Update Mongoose Dependency [Open Vulnerability]
- New Mongoosastic version
- Mongoose Transactions / rollback failure from elasticsearch
- findOneAndUpdate Auto Index Population Side Effects
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 mongoosastic.