lucene compass
PaodingAnalyzer analyzer = new PaodingAnalyzer(); String field = "contents"; QueryParser parser = new QueryParser(field, analyzer); Query query2 = parser.parse(queryStr); System.out.println("dddddddddddddddddddddd:" + query2); String str = query2.toString(); if (!str.substring(10, str.length() - 1).contains("contents")) { if (str.indexOf("\"") > 0) { str = str.substring(10, str.length() - 1); parser = new QueryParser(field, analyzer); query2 = parser.parse(str); } } BooleanQuery query = new BooleanQuery(); // query.add(query1, Occur.MUST); query.add(query2, Occur.MUST);
Compass compass = compassTemplate.getCompass(); CompassSession session = compass.openSession(); PaodingAnalyzer analyzer = new PaodingAnalyzer(); String field = "articleContent"; QueryParser parser = new QueryParser(field, analyzer); Query query2 = parser.parse(keywords); String str = query2.toString(); if (!str.substring(16, str.length() - 1).contains("articleContent")) { if (str.indexOf("\"") > 0) { str = str.substring(16, str.length() - 1); parser = new QueryParser(field, analyzer); query2 = parser.parse(str); } } System.out.println("dddddddddddddddddddddd:" + query2.toString()); CompassQuery compassQuery = session.queryBuilder() .queryString(query2.toString()).toQuery(); CompassHits hits = compassQuery.hits();
相关推荐
renjinlong 2020-09-03
Jacry 2020-07-04
IceStreamLab 2020-06-26
mengyue 2020-06-09
PasserbyX 2020-05-16
mameng 2020-05-12
心丨悦 2020-05-06
编码之路 2020-05-03
mengyue 2020-05-02
qiuzhuoxian 2020-02-23
编码之路 2020-02-20
lionelf 2020-02-03
TyCoding 2020-02-01
heniancheng 2020-01-31
某某某 2020-01-30
PinkBean 2020-01-29
某某某 2020-01-12
编码之路 2020-01-01
itmale 2020-01-01