Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 在Google App Engine中创建全文搜索索引_Google App Engine_Full Text Search - Fatal编程技术网

Google app engine 在Google App Engine中创建全文搜索索引

Google app engine 在Google App Engine中创建全文搜索索引,google-app-engine,full-text-search,Google App Engine,Full Text Search,我正在阅读谷歌应用程序引擎的全文搜索api(java)文档。他们有获取索引的示例: public Index getIndex() { IndexSpec indexSpec = IndexSpec.newBuilder() .setName("myindex") .setConsistency(Consistency.PER_DOCUMENT) .build(); return SearchServiceFac

我正在阅读谷歌应用程序引擎的全文搜索api(java)文档。他们有获取索引的示例:

public Index getIndex() {
      IndexSpec indexSpec = IndexSpec.newBuilder()
          .setName("myindex")
          .setConsistency(Consistency.PER_DOCUMENT)
          .build();
      return SearchServiceFactory.getSearchService().getIndex(indexSpec);
}
创建一个索引怎么样?如何创建一个


谢谢你刚才做的。你刚刚创造了一个

public class IndexSpec

Represents information about an index. This class is used to fully specify the index you want to retrieve from the SearchService. To build an instance use the newBuilder() method and set all required parameters, plus optional values different than the defaults.

您可以通过查看SearchService来确认这一点

SearchService is also responsible for creating new indexes. For example:
 SearchService searchService = SearchServiceFactory.getSearchService();
  index = searchService.getIndex(IndexSpec.newBuilder().setName("myindex"));

无论如何,如果不存在索引,代码似乎会创建一个新索引。这就是文件所建议的:

 // Get the index. If not yet created, create it.
  Index index = searchService.getIndex(
  IndexSpec.newBuilder()
      .setIndexName("indexName")
      .setConsistency(Consistency.PER_DOCUMENT));


现在,如果再次运行代码并更改一致性,会发生什么?是否有相同的索引具有不同的一致性?索引被覆盖了吗?我不知道。我将使用SearchService查找现有索引,而不是使用可能创建索引的代码,这样做只是为了避免试图在我的代码中获取索引,而是无意中更改规范。

在编写文档时隐式创建索引。一致性是索引的一个属性,即不能有两个同名的索引具有不同的一致性