是mongodb文本搜索忽略默认语言吗?

时间:2018-07-26 13:07:00

标签: mongodb mongodb-.net-driver

mongodb显然在文本搜索中忽略了我的默认语言。我该如何解释这种行为?

我使用c#驱动程序v2.7.0

var idxDefinition = Builders<TEntity>.IndexKeys
     .Text(entity => entity.FirstName)
     .Text(entity => entity.LastName)
     .Text(entity => entity.Email);

_collection.Indexes.CreateOne(new CreateIndexModel<TEntity(idxDefinition, new CreateIndexOptions
{
  Name = "name_text_ix",
  DefaultLanguage = "none",
  Background = true
}));
  1. db.collection.getIndexes():

    [   ...,   ...,   {     “ v”:2     “键”:     {       “ _fts”:“文字”,       “ _ftsx”:1     },     “ name”:“ name_text_ix”,     “ ns”:“ myService.collection”,     “背景”:是,     “ default_language”:“无”,     “重量”:     {       “电子邮件”:1,       “名字”:1,       “姓氏”:1     },     “ language_override”:“语言”,     “ textIndexVersion”:3   } ]

  2. db.collection.find({}):

    / * 1 * / {     “ _id”:“ 1”,     “ DateCreated”:ISODate(“ 2018-07-25T10:04:06.881Z”),     “电子邮件”:“ foo@bar.co”,     “ FirstName”:“ b”,     “ LastName”:“ Test” }

    / * 2 * / {     “ _id”:“ 2”,     “ DateCreated”:ISODate(“ 2018-07-25T10:09:42.274Z”),     “电子邮件”:“ a@test.com”,     “ FirstName”:“ a”,     “ LastName”:“ test” }

    / * 3 * / {     “ _id”:“ 3”,     “ DateCreated”:ISODate(“ 2018-07-25T10:09:50.750Z”),     “电子邮件”:“ c@test.com”,     “ FirstName”:“ c”,     “ LastName”:“ Test” }

  3. db.collection.find( { $text: { $search: "c@test.com" } } ):

    / * 1 * / {     “ _id”:“ 0cc3572ba3954c0db60cc8ca6b215601”,     “ DateCreated”:ISODate(“ 2018-07-25T10:04:06.881Z”),     “电子邮件”:“ foo @ bar”,     “ FirstName”:“ b”,     “ LastName”:“ Test” }

    / * 2 * / {     “ _id”:“ ca6f0893306d4ae4b563462e49305014”,     “ DateCreated”:ISODate(“ 2018-07-25T10:09:42.274Z”),     “电子邮件”:“ a@test.com”,     “ FirstName”:“ a”,     “ LastName”:“ test” }

    / * 3 * / {     “ _id”:“ 58275fe154954a7f9b98b900d71e9520”,     “ DateCreated”:ISODate(“ 2018-07-25T10:09:50.750Z”),     “电子邮件”:“ c@test.com”,     “ FirstName”:“ c”,     “ LastName”:“ Test” }

  4. db.collection.find( { $text: { $search: "c@test.com" } } ).explain():

    /* 1 */
    

    {     “ queryPlanner”:{         “ plannerVersion”:1         “ namespace”:“ myService.collection”,         “ indexFilterSet”:否,         “ parsedQuery”:{             “ $ text”:{                 “ $ search”:“ c@test.com”,                 “ $ language”:“无”,                 “ $ caseSensitive”:否,                 “ $ diacriticSensitive”:错误             }         },         “ winningPlan”:{             “ stage”:“ TEXT”,             “ indexPrefix”:{},             “ indexName”:“ name_text_ix”,             “ parsedTextQuery”:{                 “条款”:[                     “C”,                     “ com”,                     “测试”                 ],                 “ negatedTerms”:[],                 “词组”:[],                 “否定短语”:[]             },             “ textIndexVersion”:3,             “ inputStage”:{                 “ stage”:“ TEXT_MATCH”,                 “ inputStage”:{                     “ stage”:“ TEXT_OR”,                     “ inputStages”:[{                             “ stage”:“ IXSCAN”,                             “ keyPattern”:{                                 “ _fts”:“文字”,                                 “ _ftsx”:1                             },                             “ indexName”:“ name_text_ix”,                             “ isMultiKey”:是的,                             “ isUnique”:否,                             “ isSparse”:否,                             “ isPartial”:否,                             “ indexVersion”:2                             “ direction”:“向后”,                             “ indexBounds”:{}                         },{                             “ stage”:“ IXSCAN”,                             “ keyPattern”:{                                 “ _fts”:“文字”,                                 “ _ftsx”:1                             },                             “ indexName”:“ name_text_ix”,                             “ isMultiKey”:是的,                             “ isUnique”:否,                             “ isSparse”:否,                             “ isPartial”:否,                             “ indexVersion”:2                             “ direction”:“向后”,                             “ indexBounds”:{}                         },{                             “ stage”:“ IXSCAN”,                             “ keyPattern”:{                                 “ _fts”:“文字”,                                 “ _ftsx”:1                             },                             “ indexName”:“ name_text_ix”,                             “ isMultiKey”:是的,                             “ isUnique”:否,                             “ isSparse”:否,                             “ isPartial”:否,                             “ indexVersion”:2                             “ direction”:“向后”,                             “ indexBounds”:{}                         }                     ]                 }             }         },         “ rejectedPlans”:[]     },     “ serverInfo”:{         “ host”:“ localhost”,         “端口”:27017,         “ version”:“ 3.4.2”,         “ gitVersion”:“ 3f76e40c105fc223b3e5aac3e20dcd026b83b38b”     },     “确定”:1.0 }

    解释结果清楚地显示了停用词。是否会忽略默认语言?我该如何纠正?

0 个答案:

没有答案