在JBOSS数据网格远程缓存中执行模糊查询

时间:2018-05-14 11:36:58

标签: datagrid jboss infinispan

目前我正在尝试使用JBOSS Data GRID远程缓存中的ICKLE进行模糊查询。下面是我的.proto文件

package quickstart;

/* @Indexed */
message Person {

   /* @Field(index = true, store = true, analyze = true) */
   required string name = 1;

   /* @IndexedField(index = true, store = false) */
   required int32 id = 2;

   optional string email = 3;
   optional string address = 4;

   enum PhoneType {
      MOBILE = 0;
      HOME = 1;
      WORK = 2;
   }

   /* @Indexed */
   message PhoneNumber {

      /* @Field */
      required string number = 1;

      /* @IndexedField(index = false, store = false) */
      optional PhoneType type = 2 [default = HOME];
   }

   /* @Field(index = true, store = false) */
   repeated PhoneNumber phone = 5;
} 
}

我尝试运行以下查询

    private void queryPersonByNamebyIckelAndFuzzyDescription() {
        String namePattern = readConsole("Enter person name pattern: ");

        QueryFactory qf = Search.getQueryFactory(remoteCache);
        Query query = qf.create("FROM quickstart.Person where name : '"+namePattern+"'~2");

        List<Person> results = query.list();
        System.out.println("Found " + results.size() + " matches:");
        for (Person p : results) {
            System.out.println(">> " + p);
        }
    } 

但我得到的是异常

org.infinispan.client.hotrod.exceptions.HotRodClientException:请求messageId = 10返回服务器错误(状态= 0x85):org.infinispan.objectfilter.ParsingException:ISPN028521:全文查询无法应用于属性&# 39;名称#&39;在类型quickstart.Person中,除非对属性进行索引和分析。

1 个答案:

答案 0 :(得分:0)

以这种方式修改它会有所帮助。

package quickstart;

/* @Indexed 
@Analyzer(definition = "standard")*/
message Person {
/* @Field(store = Store.YES, analyze = Analyze.YES) */
required string name = 1;

...... .....

相关问题