Skip to content

Commit

Permalink
2.2.0 enhancments
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranmoyal committed Mar 5, 2016
1 parent 773164e commit 79f8163
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jdk:


script:
- wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.1.1/elasticsearch-2.1.1.deb && sudo dpkg -i --force-confnew elasticsearch-2.1.1.deb
- wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.2.0/elasticsearch-2.2.0.deb && sudo dpkg -i --force-confnew elasticsearch-2.2.0.deb
- sudo /usr/share/elasticsearch/bin/plugin install delete-by-query
- sudo service elasticsearch start
- sleep 10
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.nlpcn</groupId>
<artifactId>elasticsearch-sql</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<packaging>jar</packaging>
<description>Query elasticsearch using SQL</description>
<name>elasticsearch-sql</name>
Expand Down Expand Up @@ -57,7 +57,7 @@
<elasticsearch.plugin.name>sql</elasticsearch.plugin.name>
<elasticsearch.plugin.site>true</elasticsearch.plugin.site>
<elasticsearch.plugin.jvm>true</elasticsearch.plugin.jvm>
<elasticsearch.version>2.1.1</elasticsearch.version>
<elasticsearch.version>2.2.0</elasticsearch.version>
<elasticsearch.plugin.classname>org.elasticsearch.plugin.nlpcn.SqlPlug</elasticsearch.plugin.classname>

</properties>
Expand All @@ -66,13 +66,13 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>delete-by-query</artifactId>
<version>2.1.1</version>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
Expand Down Expand Up @@ -197,7 +197,7 @@ protected void addUnmatchedResults(List<InternalSearchHit> combinedResults, Coll

protected InternalSearchHit createUnmachedResult( List<Field> secondTableReturnedFields, int docId, String t1Alias, String t2Alias, SearchHit hit) {
String unmatchedId = hit.id() + "|0";
StringText unamatchedType = new StringText(hit.getType() + "|null");
Text unamatchedType = new Text(hit.getType() + "|null");

InternalSearchHit searchHit = new InternalSearchHit(docId, unmatchedId, unamatchedType, hit.getFields());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;

import org.elasticsearch.index.query.BoolQueryBuilder;
Expand Down Expand Up @@ -161,7 +161,7 @@ private List<InternalSearchHit> createCombinedResults( TableInJoinRequestBuilder



InternalSearchHit searchHit = new InternalSearchHit(matchingHit.docId(), combinedId, new StringText(matchingHit.getType() + "|" + secondTableHit.getType()), matchingHit.getFields());
InternalSearchHit searchHit = new InternalSearchHit(matchingHit.docId(), combinedId, new Text(matchingHit.getType() + "|" + secondTableHit.getType()), matchingHit.getFields());
searchHit.sourceRef(matchingHit.getSourceRef());
searchHit.sourceAsMap().clear();
searchHit.sourceAsMap().putAll(matchingHit.sourceAsMap());
Expand Down Expand Up @@ -208,7 +208,7 @@ private void createKeyToResultsAndFillOptimizationStructure(Map<String,Map<Strin
String key = getComparisonKey(t1ToT2FieldsComparison, hit, true, optimizationTermsFilterStructure.get(comparisonID));

//int docid , id
InternalSearchHit searchHit = new InternalSearchHit(resultIds, hit.id(), new StringText(hit.getType()), hit.getFields());
InternalSearchHit searchHit = new InternalSearchHit(resultIds, hit.id(), new Text(hit.getType()), hit.getFields());
searchHit.sourceRef(hit.getSourceRef());

onlyReturnedFields(searchHit.sourceAsMap(), firstTableRequest.getReturnedFields());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
import org.elasticsearch.action.search.*;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
Expand Down Expand Up @@ -115,7 +115,7 @@ private int combineResultsFromMultiResponses(List<InternalSearchHit> combinedRes

private InternalSearchHit getMergedHit(int currentCombinedResults, String t1Alias, String t2Alias, SearchHit hitFromFirstTable, SearchHit matchedHit) {
onlyReturnedFields(matchedHit.sourceAsMap(), nestedLoopsRequest.getSecondTable().getReturnedFields());
InternalSearchHit searchHit = new InternalSearchHit(currentCombinedResults, hitFromFirstTable.id() + "|" + matchedHit.getId(), new StringText(hitFromFirstTable.getType() + "|" + matchedHit.getType()), hitFromFirstTable.getFields());
InternalSearchHit searchHit = new InternalSearchHit(currentCombinedResults, hitFromFirstTable.id() + "|" + matchedHit.getId(), new Text(hitFromFirstTable.getType() + "|" + matchedHit.getType()), hitFromFirstTable.getFields());
searchHit.sourceRef(hitFromFirstTable.getSourceRef());
searchHit.sourceAsMap().clear();
searchHit.sourceAsMap().putAll(hitFromFirstTable.sourceAsMap());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/nlpcn/es4sql/AggregationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public void geoHashGrid() throws SQLFeatureNotSupportedException, SqlParseExcept
InternalGeoHashGrid grid = result.get("geohash_grid(field=center,precision=5)");
Collection<GeoHashGrid.Bucket> buckets = grid.getBuckets();
for (GeoHashGrid.Bucket bucket : buckets) {
Assert.assertTrue(bucket.getKey().toString().equals("[4.9658203125, 104.9853515625]") || bucket.getKey().toString().equals("[0.4833984375, 100.458984375]") );
Assert.assertTrue(bucket.getKey().toString().equals("4.9658203125,104.9853515625") || bucket.getKey().toString().equals("0.4833984375,100.458984375") );
Assert.assertEquals(1,bucket.getDocCount());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/nlpcn/es4sql/CSVResultsExtractorTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ public void simpleSearchResultWithNestedWithFlatNoAggs() throws SqlParseExceptio
}
@Test
public void joinSearchResultNotNestedNotFlatNoAggs() throws SqlParseException, SQLFeatureNotSupportedException, Exception {
String query = String.format("select c.gender , h.name,h.words from %s/gotCharacters c " +
String query = String.format("select c.gender , h.hname,h.words from %s/gotCharacters c " +
"JOIN %s/gotHouses h " +
"on h.name = c.house ",TEST_INDEX,TEST_INDEX);
"on h.hname = c.house ",TEST_INDEX,TEST_INDEX);
CSVResult csvResult = getCsvResult(false, query);

List<String> headers = csvResult.getHeaders();
Assert.assertEquals(3, headers.size());
Assert.assertTrue("c.gender should be on headers", headers.contains("c.gender"));
Assert.assertTrue("h.words should be on headers", headers.contains("h.words"));
Assert.assertTrue("h.hname should be on headers", headers.contains("h.hname"));
Assert.assertTrue("h.words should be on headers", headers.contains("h.words"));

List<String> lines = csvResult.getLines();
Expand Down
Loading

0 comments on commit 79f8163

Please sign in to comment.