CustomQueryStringParser { protected Query getQuery(List<CrescentCollectionField> indexedFields, String customQueryString, Analyzer analyzer, String regexQueryString) throws CrescentInvalidRequestException { if(resultQuery != null) { return this.resultQuery; } else { return getQueryFromCustomQuery(indexedFields, customQueryString, analyzer, regexQueryString); } }    }
@Test public void normalTermQueryWithDefaultFieldBoost() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("title:\"파이썬 프로그래밍 공부\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("title:파이썬^2.0 title:파이^2.0 title:프로그래밍^2.0 title:공부^2.0", query.toString()); }
@Test public void multipleTermQueryWithDefaultFieldBoost() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("title:\"파이썬 프로그래밍 공부\" +dscr:\"자바 병렬 프로그래밍\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("title:파이썬^2.0 title:파이^2.0 title:프로그래밍^2.0 title:공부^2.0 +dscr:자바 +dscr:병렬 +dscr:프로그래밍", query.toString()); }
@Test public void normalTermQueryWithCustomBoost() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("dscr:\"파이썬 프로그래밍 공부^10\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("dscr:파이썬^10.0 dscr:파이^10.0 dscr:프로그래밍^10.0 dscr:공부^10.0", query.toString()); }
@Test public void normalTermQueryWithDefaultFieldBoostAndCustomBoost() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("title:\"파이썬 프로그래밍 공부^10\" dscr:\"파이썬 프로그래밍 공부^10\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("title:파이썬^12.0 title:파이^12.0 title:프로그래밍^12.0 title:공부^12.0 dscr:파이썬^10.0 dscr:파이^10.0 dscr:프로그래밍^10.0 dscr:공부^10.0", query.toString()); }
@Test(expected = CrescentInvalidRequestException.class) public void complexQueryWithDefaultFieldBoostAndCustomBoostException() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("title:\"파이썬 프로그래밍 공부^10\" dscr:\"파이썬 프로그래밍 공부^10\" title:\"[50 TO 50000]\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("title:파이썬^12.0 title:파이^12.0 title:프로그래밍^12.0 title:공부^12.0 dscr:파이썬^10.0 dscr:파이^10.0 dscr:프로그래밍^10.0 dscr:공부^10.0 title:[50 TO 50000]", query.toString()); }
@Test public void complexQueryWithDefaultFieldBoostAndCustomBoost() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("title:\"파이썬 프로그래밍 공부^10\" dscr:\"파이썬 프로그래밍 공부^10\" board_id:\"[50 TO 50000]\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("title:파이썬^12.0 title:파이^12.0 title:프로그래밍^12.0 title:공부^12.0 dscr:파이썬^10.0 dscr:파이^10.0 dscr:프로그래밍^10.0 dscr:공부^10.0 board_id:[50 TO 50000]", query.toString()); }
@Test public void rangeQuery() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("board_id:\"[10 TO 100000]\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("board_id:[10 TO 100000]", query.toString()); }
@Test(expected = CrescentInvalidRequestException.class) public void rangeQueryNoSearchField() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("field1:\"[10 TO 100000]\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); }
@Test public void normalTermQuery() throws CrescentInvalidRequestException { SearchRequest searchRequest = new SearchRequest(); searchRequest.setCollectionName("sample"); searchRequest.setCustomQuery("dscr:\"파이썬 프로그래밍 공부\""); CrescentSearchRequestWrapper csrw = new CrescentSearchRequestWrapper(searchRequest); Query query = csrw.getQuery(); System.out.println(query); Assert.assertEquals("dscr:파이썬 dscr:파이 dscr:프로그래밍 dscr:공부", query.toString()); }