简体   繁体   中英

Searching an elasticsearch index with NEST yields no results

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM