Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 36F28200D4A for ; Tue, 28 Nov 2017 18:40:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 354E4160C07; Tue, 28 Nov 2017 17:40:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7B21E160BE7 for ; Tue, 28 Nov 2017 18:40:45 +0100 (CET) Received: (qmail 94233 invoked by uid 500); 28 Nov 2017 17:40:44 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 94222 invoked by uid 99); 28 Nov 2017 17:40:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2017 17:40:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 99CF11A0A68 for ; Tue, 28 Nov 2017 17:40:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.874 X-Spam-Level: ** X-Spam-Status: No, score=2.874 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FORGED_YAHOO_RCVD=1.022, NML_ADSP_CUSTOM_MED=1.2, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 9xUHykfBpyNf for ; Tue, 28 Nov 2017 17:40:42 +0000 (UTC) Received: from n6.nabble.com (n6.nabble.com [162.255.23.37]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8E99F5F19D for ; Tue, 28 Nov 2017 17:40:41 +0000 (UTC) Received: from n6.nabble.com (localhost [127.0.0.1]) by n6.nabble.com (Postfix) with ESMTP id 1835D324975F for ; Tue, 28 Nov 2017 10:40:40 -0700 (MST) Date: Tue, 28 Nov 2017 10:40:40 -0700 (MST) From: zbyszek To: user@ignite.apache.org Message-ID: <1511890840095-0.post@n6.nabble.com> Subject: Lucene query syntaxt support in TextQuery ? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Tue, 28 Nov 2017 17:40:46 -0000 Hello All, I wonder if anybody could help with the following: I am trying to get Lucene syntax working in my code below. According to this post - http://apache-ignite-users.70518.x6.nabble.com/Can-TextQuery-specify-only-one-field-of-the-class-td2300.html fielded data should be supported (like TextQuery(Person.class, "resume:Master");), but cannot get it running for some reason. Could you advise? Thank you in advance, zbyszek private static void test() { // start ignite IgniteConfiguration iCfg = new IgniteConfiguration(); String workDirectory = System.getProperty("user.home") + File.separator + "ignite"; iCfg.setWorkDirectory(workDirectory); System.out.println(String.format(">>> Starting cache. Working directory %s ...", workDirectory)); Ignite ignite = Ignition.start(iCfg); System.out.println(">>> Cache started successfully"); // configure cache CacheConfiguration cCfg = new CacheConfiguration<>(); cCfg.setName("MyCache"); cCfg.setStoreKeepBinary(true); cCfg.setCacheMode(CacheMode.LOCAL); cCfg.setCopyOnRead(false); cCfg.setBackups(0); cCfg.setWriteBehindEnabled(false); cCfg.setReadThrough(false); cCfg.setWriteThrough(false); // define query QueryEntity qe = new QueryEntity(Long.class.getTypeName(),"MyValue"); qe.addQueryField("text1", String.class.getTypeName(), "text1"); qe.addQueryField("text2", String.class.getTypeName(), "text2"); LinkedHashMap f1 = new LinkedHashMap<>(); f1.put("text1", false); QueryIndex idx1 = new QueryIndex(f1, QueryIndexType.FULLTEXT); idx1.setName("idx1"); LinkedHashMap f2 = new LinkedHashMap<>(); f2.put("text2", false); QueryIndex idx2 = new QueryIndex(f2, QueryIndexType.FULLTEXT); idx2.setName("idx2"); qe.setIndexes(Arrays.asList(idx1, idx2)); cCfg.setQueryEntities(Collections.singletonList(qe)); IgniteCache cache = ignite.createCache(cCfg).withKeepBinary(); // insert data IgniteBinary binary = ignite.binary(); BinaryObjectBuilder builder = binary.builder("MyValue"); builder.setField("id", 0L); builder.setField("text1", "Apache"); builder.setField("text2", "Ignite"); cache.put(0L, builder.build()); builder.setField("id", 1L); builder.setField("text1", "Ignite"); builder.setField("text2", "Apache"); cache.put(1L, builder.build()); builder.setField("id", 2L); builder.setField("text1", "Apache"); builder.setField("text2", "Spark"); cache.put(2L, builder.build()); // working query TextQuery goodQuery = new TextQuery<>("MyValue", "S*"); QueryCursor> results1 = cache.query(goodQuery); results1.forEach(entry -> { System.out.println(">>> (1) " + entry.getValue()); }); // failing query TextQuery badQuery = new TextQuery<>("MyValue", "text1:Apache"); QueryCursor> results2 = cache.query(badQuery); results2.forEach(entry -> { System.out.println(">>> (2) " + entry.getValue()); }); // cleanup cache.destroy(); ignite.close(); } -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/