Skip to content

Commit 0170571

Browse files
committed
update dinst* to default value
1 parent 5e603bb commit 0170571

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

src/main/java/org/nlpcn/es4sql/parse/FieldMaker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import org.nlpcn.es4sql.domain.KVValue;
99
import org.nlpcn.es4sql.domain.MethodField;
1010
import org.nlpcn.es4sql.exception.SqlParseException;
11-
1211
import org.durid.sql.ast.SQLExpr;
1312
import org.durid.sql.ast.expr.SQLAggregateExpr;
1413
import org.durid.sql.ast.expr.SQLAggregateExpr.Option;
1514
import org.durid.sql.ast.expr.SQLAllColumnExpr;
1615
import org.durid.sql.ast.expr.SQLBinaryOpExpr;
1716
import org.durid.sql.ast.expr.SQLIdentifierExpr;
1817
import org.durid.sql.ast.expr.SQLMethodInvokeExpr;
18+
import org.durid.sql.ast.expr.SQLPropertyExpr;
1919
import org.durid.sql.ast.expr.SQLQueryExpr;
2020

2121
/**
@@ -26,7 +26,7 @@
2626
*/
2727
public class FieldMaker {
2828
public static Field makeField(SQLExpr expr, String alias) throws SqlParseException {
29-
if (expr instanceof SQLIdentifierExpr) {
29+
if (expr instanceof SQLIdentifierExpr || expr instanceof SQLPropertyExpr) {
3030
return new Field(expr.toString(), alias);
3131
} else if (expr instanceof SQLQueryExpr) {
3232
throw new SqlParseException("unknow field name : " + expr);

src/main/java/org/nlpcn/es4sql/query/maker/AggMaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private RangeBuilder rangeBuilder(MethodField field) {
195195
*/
196196
private AbstractAggregationBuilder makeCountAgg(MethodField field) {
197197
if ("DISTINCT".equals(field.getOption())) {
198-
return AggregationBuilders.cardinality(field.getAlias()).field(field.getParams().get(0).value.toString());
198+
return AggregationBuilders.cardinality(field.getAlias()).precisionThreshold(40000).field(field.getParams().get(0).value.toString());
199199
}
200200
String fieldName = field.getParams().get(0).value.toString();
201201
if ("*".equals(fieldName)) {

src/test/java/org/nlpcn/es4sql/ErrorTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class ErrorTest {
2020

21-
private SearchDao searchDao = new SearchDao("ky_ESearch", "172.21.19.59", 9300);
21+
private SearchDao searchDao = new SearchDao("ky_ESearch", "172.21.19.57", 9300);
2222

2323
@Test
2424
public void dayGAndL() throws IOException, SqlParseException {
@@ -44,11 +44,19 @@ public void dayGAndL() throws IOException, SqlParseException {
4444
//
4545
// System.out.println(execute);
4646

47-
// SearchResponse execute = searchDao.execute("select count(*) from heartbeat/2014-10-15 "
47+
// SearchResponse execute = searchDao.execute("select count(*) from heartbeat "
4848
// + " group by date_histogram(field='log_time','interval'='1H','format'='yyyy-MM-dd HH:mm:ss'),"
4949
// + "range(tvId,0,1,10000)");
5050

51-
SearchResponse execute = searchDao.execute("SELECT count(certificateCode) FROM heartbeat/2014-10-16") ;
51+
// SearchResponse execute = searchDao.execute("SELECT count(certificateCode) FROM heartbeat/2014-10-16") ;
52+
//
53+
// System.out.println(execute);machineType
54+
// System.out.println(searchDao.explan("select count(clientInfo.clientId), count(distinct clientInfo.clientId) from adlog where invoke_date_int=20141017 and adDetailInfo.advertiserId=4 group by invoke_date_int"));
55+
// SearchResponse execute = searchDao.execute("select count(clientInfo.clientId), count(distinct clientInfo.clientId) from adlog where invoke_date_int=20141017 and adDetailInfo.advertiserId=4 group by invoke_date_int") ;
56+
//
57+
//
58+
// System.out.println(execute);
59+
SearchResponse execute = searchDao.execute("select count(distinct certificateCode) as total from heartbeat/2014-10-26 group by vendorId, machineType") ;
5260

5361
System.out.println(execute);
5462

src/test/java/org/nlpcn/es4sql/Test.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020

2121
public class Test {
2222
public static void main(String[] args) throws IOException, SqlParseException, ParseException {
23-
SearchDao searchDao = new SearchDao("ky_ESearch", "172.21.19.57", 9300);
24-
String sql = "SELECT COUNT(DISTINCT path) FROM adlog group by path limit 3 order by COUNT(DISTINCT path)";
25-
ActionResponse select = searchDao.execute(sql);
26-
System.out.println(select);
23+
System.out.println(System.currentTimeMillis()-8*60*3600);
24+
System.out.println(System.currentTimeMillis()-7*60*3600);
25+
// SearchDao searchDao = new SearchDao("ky_ESearch", "172.21.19.57", 9300);
26+
// String sql = "SELECT COUNT(DISTINCT path) FROM adlog group by path limit 3 order by COUNT(DISTINCT path)";
27+
// ActionResponse select = searchDao.execute(sql);
28+
// System.out.println(select);
2729
}
2830

2931
public static void importData() throws IOException {

src/test/java/org/nlpcn/es4sql/TestImportTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ public static void main(String[] args) throws IOException {
1818
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
1919
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("/home/ansj/temp/20140421.txt"))));
2020
String temp = null;
21+
22+
int a = 0 ;
2123

2224
while ((temp = br.readLine()) != null) {
23-
24-
System.out.println("in");
25+
if(a++%100==0)
26+
System.out.println(a);
2527
try {
2628
JSONObject job = JSON.parseObject(br.readLine());
27-
client.prepareIndex().setIndex("testdoc").setType("testdoc").setSource(job).execute().actionGet();
29+
client.prepareIndex().setIndex("testdoc").setType("testdoc").setSource(job).setTimeout("10s").execute().actionGet();
2830
} catch (Exception e) {
2931
e.printStackTrace();
3032
}

0 commit comments

Comments
 (0)