本文整理汇总了Java中com.google.appengine.api.search.Index.getSchema方法的典型用法代码示例。如果您正苦于以下问题:Java Index.getSchema方法的具体用法?Java Index.getSchema怎么用?Java Index.getSchema使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.search.Index
的用法示例。
在下文中一共展示了Index.getSchema方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
PrintWriter out = resp.getWriter();
Document doc = Document.newBuilder()
.setId("theOnlyCar")
.addField(Field.newBuilder().setName("maker").setText("Toyota"))
.addField(Field.newBuilder().setName("price").setNumber(300000))
.addField(Field.newBuilder().setName("color").setText("lightblue"))
.addField(Field.newBuilder().setName("model").setText("Prius"))
.build();
try {
Utils.indexADocument(SEARCH_INDEX, doc);
} catch (InterruptedException e) {
// ignore
}
// [START list_schema]
GetResponse<Index> response = SearchServiceFactory.getSearchService().getIndexes(
GetIndexesRequest.newBuilder().setSchemaFetched(true).build());
// List out elements of each Schema
for (Index index : response) {
Schema schema = index.getSchema();
for (String fieldName : schema.getFieldNames()) {
List<FieldType> typesForField = schema.getFieldTypes(fieldName);
// Just printing out the field names and types
for (FieldType type : typesForField) {
out.println(index.getName() + ":" + fieldName + ":" + type.name());
}
}
}
// [END list_schema]
}
示例2: doGet
import com.google.appengine.api.search.Index; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
PrintWriter out = resp.getWriter();
Document doc =
Document.newBuilder()
.setId("theOnlyCar")
.addField(Field.newBuilder().setName("maker").setText("Toyota"))
.addField(Field.newBuilder().setName("price").setNumber(300000))
.addField(Field.newBuilder().setName("color").setText("lightblue"))
.addField(Field.newBuilder().setName("model").setText("Prius"))
.build();
try {
Utils.indexADocument(SEARCH_INDEX, doc);
} catch (InterruptedException e) {
// ignore
}
// [START list_schema]
GetResponse<Index> response =
SearchServiceFactory.getSearchService()
.getIndexes(GetIndexesRequest.newBuilder().setSchemaFetched(true).build());
// List out elements of each Schema
for (Index index : response) {
Schema schema = index.getSchema();
for (String fieldName : schema.getFieldNames()) {
List<FieldType> typesForField = schema.getFieldTypes(fieldName);
// Just printing out the field names and types
for (FieldType type : typesForField) {
out.println(index.getName() + ":" + fieldName + ":" + type.name());
}
}
}
// [END list_schema]
}