Skip to content
This repository has been archived by the owner on Oct 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/bcui/sensei
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhabiuk committed May 5, 2012
2 parents 634fe2a + 1a56532 commit c1e5b91
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bin/sensei-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

python $bin/../clients/python/sensei/sensei_client.py $1 $2

python $bin/../clients/python/sensei/sensei_client.py $*
2 changes: 1 addition & 1 deletion clients/python/sensei/sensei_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def help():

if command == "select":
res = client.doQuery(stmt, var_map=var_map)
error = res.errors[0]
error = res.errors and res.errors[0] or None
if error:
err_code = error.get(PARAM_RESULT_ERROR_CODE)
err_msg = error.get(PARAM_RESULT_ERROR_MESSAGE)
Expand Down
2 changes: 1 addition & 1 deletion sensei-core/src/main/antlr3/com/senseidb/bql/parsers/BQL.g
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ import java.text.SimpleDateFormat;
else if (columnType.equals("float") || columnType.equals("double")) {
return !(value instanceof String || value instanceof Boolean);
}
else if (columnType.equals("string")) {
else if (columnType.equals("string") || columnType.equals("char")) {
return (value instanceof String);
}
else if (columnType.equals("boolean")) {
Expand Down
10 changes: 10 additions & 0 deletions sensei-core/src/main/java/com/senseidb/util/RequestConverter2.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ else if (selections instanceof JSONObject)
JSONObject jsonParamValues = jsonParams.getJSONObject(paramName);
String type = jsonParamValues.optString(RequestConverter2.FACETINIT_TYPE, RequestConverter2.FACETINIT_TYPE_STRING);
JSONArray jsonValues = jsonParamValues.optJSONArray(RequestConverter2.FACETINIT_VALUES);
if (jsonValues == null)
{
// Accept scalar values here too. This is useful in
// supporting variable substitutions.
Object value = jsonParamValues.opt(RequestConverter2.FACETINIT_VALUES);
if (value != null)
{
jsonValues = new JSONArray().put(value);
}
}
if (jsonValues != null)
{
if (type.equals(RequestConverter2.FACETINIT_TYPE_INT))
Expand Down
13 changes: 13 additions & 0 deletions sensei-core/src/test/java/com/senseidb/test/TestSensei.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void testSelectionTerms() throws Exception
JSONObject res = search(new JSONObject(req));
assertEquals("numhits is wrong", 4483, res.getInt("numhits"));
}

public void testSelectionDynamicTimeRangeJson() throws Exception
{
logger.info("executing test case Selection terms");
Expand All @@ -293,6 +294,18 @@ public void testSelectionDynamicTimeRangeJson() throws Exception
assertEquals("numhits is wrong", 12990, res.getInt("numhits"));
}

public void testSelectionDynamicTimeRangeJson2() throws Exception
{
// Test scalar values in facet init parameters
logger.info("executing test case Selection terms");
String req = "{\"selections\":[{\"term\":{\"timeRange\":{\"value\":\"000000013\"}}}]" +
", \"facetInit\":{ \"timeRange\":{\"time\" :{ \"type\" : \"long\",\"values\" : 15000 }}}" +
"}";
System.out.println(req);
JSONObject res = search(new JSONObject(req));
assertEquals("numhits is wrong", 12990, res.getInt("numhits"));
}

public void testSelectionRange() throws Exception
{
//2000 1548;
Expand Down

0 comments on commit c1e5b91

Please sign in to comment.