2014-01-29 56 views
2

我正在玩NEST,并且正在向ES索引添加东西时没有任何问题。但是,取回任何结果是另一回事。使用NEST搜索elasticsearch索引不会产生结果

下面是我的浏览器的输出/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 
} 
    } ] 
    } 
} 

这里是我的NEST来电:

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

我得到一个空回当我运行它。 (QueryString搜索也不起作用。)使查询不太具体(.AllIndices())不会改变结果。

任何想法?

回答

0

既然你没有明确说法的返回类型应该是NEST什么将承担Search<dynamic>

如果你这样做,你需要明确地告诉它的索引或键入您希望通过在或.AllIndices()和/或.AllTypes()搜索

+0

我使用了elasticsearch.org的Twitter示例,并使用'.AllIndices()。AllTypes()'返回了我添加到'twitter'索引中的三个文档。没有从'nest-testing'索引返回。看看嵌套测试JSON的结构,我想我可能会错误地创建索引。 (所有东西都塞进'_source'里面 - 这不是我想要的 - 所以我想我可能会在上游做更错的事情。) – rianjs

相关问题