Coder Social home page Coder Social logo

Comments (23)

wedgemartin avatar wedgemartin commented on July 25, 2024 3

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.

guumaster avatar guumaster commented on July 25, 2024 1

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.

guumaster avatar guumaster commented on July 25, 2024

All Elasticsearch properties must be prefixed with "es_". Try changing index: 'not_analyzed' to es_index: 'not_analyzed'

from mongoosastic.

hengkiardo avatar hengkiardo commented on July 25, 2024

@guumaster i also have been using like what you mention, but it not working.

from mongoosastic.

guumaster avatar guumaster commented on July 25, 2024

@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.

davidsandoz avatar davidsandoz commented on July 25, 2024

@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.

davidsandoz avatar davidsandoz commented on July 25, 2024

@guumaster Do you have an idea of where else I should try to look to fix that problem?

from mongoosastic.

guumaster avatar guumaster commented on July 25, 2024

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.

chakravarthysm avatar chakravarthysm commented on July 25, 2024

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.

guumaster avatar guumaster commented on July 25, 2024

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.

hengkiardo avatar hengkiardo commented on July 25, 2024

@guumaster can you past to us how you define your Schema when using mongoosastic

from mongoosastic.

eferesen avatar eferesen commented on July 25, 2024

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.

prasadbhosale avatar prasadbhosale commented on July 25, 2024

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.

francesconero avatar francesconero commented on July 25, 2024

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.

nschloe avatar nschloe commented on July 25, 2024

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.

michelem09 avatar michelem09 commented on July 25, 2024

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.

anton6 avatar anton6 commented on July 25, 2024

Thanks guumaster, worked for me. I am also calling createMapping after schema definition by the way.

from mongoosastic.

jonnadams avatar jonnadams commented on July 25, 2024

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.

oussama avatar oussama commented on July 25, 2024

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.

dmr07 avatar dmr07 commented on July 25, 2024

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.

d4goxn avatar d4goxn commented on July 25, 2024

@danielmeng07 es_indexed seems to be correct, not es_index.

from mongoosastic.

stale avatar stale commented on July 25, 2024

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.

stale avatar stale commented on July 25, 2024

Closing this issue due to lack of activity. Thank you for your contributions.

from mongoosastic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.