为了简化创建 IndexName 或者 Indices 实例,Nest.Indices 包含了好几个静态方法供使用。
单索引
单索引可以通过使用 CLR 类、字符串或者 .Index() 方法来进行指定。
1 2 3 4 5 6 7 8 9 10
var client = TestClient.Default;
var singleString = Nest.Indices.Index("name1"); //通过字符串"name1"进行指定 var singleTyped = Nest.Indices.Index<Project>(); //通过 Project 类进行指定。
ISearchRequest singleStringRequest = new SearchDescriptor<Project>().Index(singleString); ISearchRequest singleTypedRequest = new SearchDescriptor<Project>().Index(singleTyped);
var manyStrings = Nest.Indices.Index("name1", "name2"); // 使用字符串 var manyTypes = Nest.Indices.Index<Project>().And<Developer>(); //使用 CLR 类 var client = TestClient.Default;
ISearchRequest manyStringRequest = new SearchDescriptor<Project>().Index(manyStrings); ISearchRequest manyTypedRequest = new SearchDescriptor<Project>().Index(manyTypes);
var indicesAll = Nest.Indices.All; var allIndices = Nest.Indices.AllIndices;
ISearchRequest indicesAllRequest = new SearchDescriptor<Project>().Index(indicesAll); ISearchRequest allIndicesRequest = new SearchDescriptor<Project>().Index(allIndices);