我使用Searchblox来索引和搜索我的文件,这些文件本身称为ES 2.x来完成这项工作。 Searchblox在创建索引时使用“mapping.json”文件来初始化映射。这是该文件的link。作为“@Russ凸轮”建议here,我创建了自己的类的内容用下面的代码(像他一样的“问题”指数和“问题”类):无法从elasticsearch获取NEST的任何文档
public class Content
{
public string type { get; set; }
public Fields fields { get; set; }
}
public class Fields
{
public Content1 content { get; set; }
public Autocomplete autocomplete { get; set; }
}
public class Content1
{
public string type { get; set; }
public string store { get; set; }
public string index { get; set; }
public string analyzer { get; set; }
public string include_in_all { get; set; }
public string boost { get; set; }
} //got this with paste special->json class
从内容类的这些字段(类型,存储等)来自上面附带的mapping.json文件。现在,当我(就像你对我)执行以下代码:
var searchResponse = highLevelclient.Search<Content>(s => s.Query(q => q
.Match(m => m.Field(f => f.fields.content)
.Query("service")
我得到的是对searchResponse变量的回应是:
Valid NEST response built from a successful low level call on POST: /idx014/content/_search
Audit trail of this API call:
-HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.7180404
Request:
{"query":{"match":{"fields.content":{"query":"service"}}}}
Response:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
And no documents in searchResponse.Documents. Contradictorily, when I search for the "service" query on Searchblox or make an API call to localhost:9200 with the Sense extension of Google Chrome, I get 2 documents. (the documents that I was looking for)
总之,我要的是能:
- 得到的所有文件(无标准)
- 得到一个时间范围内的所有文件和基于关键词的..如“服务”
我在做什么错?如有需要,我可以提供更多信息。谢谢大家的详细解答。
我调试了以下行: var searchResponse = highLevelclient.Search(s => query(q => q .Match(m => m.Field(f => f.fields.content).Query(“服务“) 并得到以下内容:[error](https://drive.google.com/open?id=0B1LnMWaj1afaQ0ltd0ExVGc3OTQ)。 为什么我得到_“方法只能在Type.IsGenericParameter为true的类型上调用。”_错误?这个错误是否必须对我执行任何操作** get ** **文档? –
cemowski23
您最好直接使用Searchblox api获取json或xml格式的文档。 – user7313404
此外,请检查基本身份验证凭据以访问elasticsearch @ 9200,因为Searchblox在访问数据之前提供了一个安全层。 – user7313404