使用NEST搜索弹性搜索索引不会产生结果 [英] Searching an elasticsearch index with NEST yields no results

查看:142
本文介绍了使用NEST搜索弹性搜索索引不会产生结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩NEST,我正在向ES索引添加东西,没有任何问题。返回的任何结果是另一回事。



以下是我的浏览器中的 / nest-testing / _search /?pretty

  {
take:0,
timed_out:false,
_shards:{
total:5,
success:5,
failed:0
},
hits :{
total:1,
max_score:1.0,
hits:[{
_index:nest-testing,
_type:plain_text,
_id:\\\\domain.net\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ b_score:1.0,_source:{
id:\\\\domain.net\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ,
full_unc_path:\\\\domain.net\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ .txt,
parent_directory:\\\\domain.net\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ,
date_created:2014-01-28T15:47:30.4302806Z,
date_modified:2014-01-29T15:47:30.4302806Z,
fulltext :另外,我喜欢意大利面和肉丸子,
original_filesize:37,
extracted_text_size:37
}
}]
}
}

这是我的NEST电话:

  var result = client.Search(s => s 
.Index(TEST_INDEX)
.MatchAll()
);

当我运行它时,我收到一个空的集合。 (QueryString搜索不起作用。)使查询不太具体( .AllIndices())不会更改结果。



任何想法?

解决方案

由于您没有明确说明返回类型应该是什么 NEST 将承担搜索< dynamic>



如果你这样做需要明确地告诉您要搜索的索引或类型,或 .AllIndices()和/或 .AllTypes()


I'm playing around with NEST, and I'm adding stuff to the ES index without any problems. Getting any results back is another matter, however.

Here's the output in my browser for /nest-testing/_search/?pretty

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "nest-testing",
      "_type" : "plain_text",
      "_id" : "\\\\domain.net\\path\\to\\lorem.txt",
      "_score" : 1.0, "_source" : {
  "id": "\\\\domain.net\\path\\to\\lorem.txt",
  "full_unc_path": "\\\\domain.net\\path\\to\\lorem.txt",
  "file_name": "lorem.txt",
  "parent_directory": "\\\\domain.net\\path\\to\\lorem",
  "date_created": "2014-01-28T15:47:30.4302806Z",
  "date_modified": "2014-01-29T15:47:30.4302806Z",
  "fulltext": "Also, I like spaghetti and Meatballs.",
  "original_filesize": 37,
  "extracted_text_size": 37
}
    } ]
  }
}

Here's my NEST call:

var result = client.Search(s => s
    .Index(TEST_INDEX)
    .MatchAll()
);

I get an empty collection back when I run it. (QueryString searches don't work, either.) Making the query less specific ( .AllIndices() ) doesn't change the result.

Any ideas?

解决方案

Since you are not explicitly saying what the return type should be NEST will assume Search<dynamic>

If you do so you need to explicitly tell it which index or type you want to search through at or .AllIndices() and/or .AllTypes()

这篇关于使用NEST搜索弹性搜索索引不会产生结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆