Skip to content
Browse files

Restore deleted json files for tests.

  • Loading branch information...
1 parent 88662db commit e5521b540f81aed47d1b8aa668fb1ce08544ad04 @wonlay wonlay committed
View
8 sensei-core/src/test/java/com/sensei/test/TestRequestConverter2.java
@@ -72,10 +72,10 @@ public static JSONArray readJSONArrayFromFile(String fileName) throws Exception
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
- senseiRequestJson = readJSONFromFile("../clients/javascript/sensei-request.json");
- selectionsJson = readJSONArrayFromFile("../clients/javascript/selections.json");
- queryJson = readJSONFromFile("../clients/javascript/queries.json");
- filtersJson = readJSONFromFile("../clients/javascript/filters.json");
+ senseiRequestJson = readJSONFromFile("src/test/json/sensei-request.json");
+ selectionsJson = readJSONArrayFromFile("src/test/json/selections.json");
+ queryJson = readJSONFromFile("src/test/json/queries.json");
+ filtersJson = readJSONFromFile("src/test/json/filters.json");
senseiRequestJson.remove("selections");
senseiRequestJson.remove("query");
View
134 sensei-core/src/test/json/filters.json
@@ -0,0 +1,134 @@
+{
+ //id filter
+ "ids":{
+ "values":[
+ "1",
+ "4",
+ "100"
+ ],
+ "excludes":[
+ "5"
+ ]
+ },
+ //and filter
+ "and":[
+ {
+ "term":{
+ "color":{
+ "value":"red",
+ "_noOptimize":false
+ }
+ }
+
+ },
+ {
+ "query":{
+ "query_string":{
+ "query":"this AND that OR thus"
+ }
+ }
+ }
+ ],
+ //or filter
+ "or":[
+ {
+ "term":{
+ "color":{
+ "value":"red",
+ "_noOptimize":false
+ }
+ }
+ },
+ {
+ "term":{
+ "category":{
+ "value":"van",
+ "_noOptimize":false
+ }
+ }
+ }
+ ],
+ //boolean filter
+ "bool":{
+ "must":{
+ "term":{
+ "tag":"wow"
+ }
+ },
+ "must_not":{
+ "range":{
+ "age":{
+ "from":10,
+ "to":20
+ }
+ }
+ },
+ "should":[
+ {
+ "term":{
+ "tag":"sometag"
+ }
+ },
+ {
+ "term":{
+ "tag":"sometagtag"
+ }
+ }
+ ]
+ },
+ //term filter
+ "term":{
+ "color":{
+ "value":"red",
+ "_noOptimize":false
+ }
+ },
+ //query filter
+ //see queries.json for a list of valid queries
+ "query":{
+ "query_string":{
+ "query":"this AND that OR thus"
+ }
+ },
+ "terms":{
+ "tags":{
+ "values":[
+ "blue",
+ "pill"
+ ],
+ "excludes":[
+ "red"
+ ],
+ "operator":"or",
+ "_noOptimize":false
+ }
+ //or// "tags":[ "blue","pill"], default operator or
+ },
+ //range filter
+ //see range query
+ "range":{
+ "age":{
+ "from":10,
+ "to":20,
+ "_noOptimize":false,
+ "_type":"int", //when _noOptimize is true and the data of 'from' and 'to' field fit into the following types,
+ // we have to specify the type here.
+ // currently these types have to be specified: "int","short","long","float","double", "date".
+ "_date_format":"yyyyMMdd-kk:mm" // if the type is date, format needs to be specified, "from" "to" are long;
+ }
+ },
+ "selection":{
+ "term":{
+
+ },
+ "terms":{
+
+ },
+ "range":{
+
+ },
+ "path":{
+
+ }
+ }
+}
View
195 sensei-core/src/test/json/queries.json
@@ -0,0 +1,195 @@
+// default field names:
+// _all : default field
+// _uid: uid field
+
+// match all docs query
+{
+
+ "match_all" : {
+ "boost" : 1.2 // boost, optional, if not specified, Lucene default will be used
+ },
+
+// id query
+ "ids" : {
+ "values" : ["1","4","100"],
+ "excludes" : ["5"],
+ "boost" : 1.0
+ },
+
+// query string
+// constructs a Lucene QueryParser and parses the query text
+ "query_string" : {
+ "default_field" : "contents", // if not specified, defaults to: contents
+ "query" : "this AND that OR thus", // if null, defaults to match all docs query, all other parameters are ignored
+ "default_operator" : "AND", // default operator, default: OR
+ "allow_leading_wildcard" : false, // default: ture
+ "lowercase_expanded_terms" : false, // default: true
+ "enable_position_increments" : false, // default: true
+ "fuzzy_prefix_length" : 0, // default: 0
+ "fuzzy_min_sim" : 0.5, // default: 0.5f
+ "phrase_slop" : 0, // default: 0
+ "boost" : 1.0, // default: 1.0
+ "auto_generate_phrase_queries": false, // default: false,
+
+ // multi field
+ "fields" : ["content","name^5"],
+ "use_dis_max": true,
+ "tie_breaker": 0
+ },
+
+// text query
+ "text" : {
+ "message" : "this is a test", // field: "message", query: "this is a test"
+ "operator" : "or", // operator, possible values: "and", "or"
+ "type" : "phrase" // query type, can be "phrase", "phrase_prefix"
+ },
+
+// term query
+ "term" : {
+ "color" : "red"
+
+ // or "color" : {"value" : "red", "boost": 2.0}
+ },
+
+// boolean query
+ "bool" : {
+ "must" : {
+ "term" : { "color" : "red" }
+ },
+ "must_not" : {
+ "range" : {
+ "age" : { "from" : 10, "to" : 20 }
+ }
+ },
+ "should" : [
+ {
+ "term" : { "tag" : "wow"}
+ },
+ {
+ "term" : { "tag" : "search"}
+ }
+ ],
+ "minimum_number_should_match" : 1, // if there is no should item above, this one will be ignored;
+ "boost" : 1.0,
+ "disable_coord" : false // optional: default = false
+ },
+
+// dist max
+ "dis_max" : {
+ "tie_breaker" : 0.7,
+ "boost" : 1.2,
+ "queries" : [
+ {
+ "term" : { "age" : 34 }
+ },
+ {
+ "term" : { "age" : 35 }
+ }
+ ]
+ },
+
+ "path" : {
+ "city" : "china/beijing"
+ },
+
+// prefix
+ "prefix" : {
+ "user" : "ki"
+
+ // or
+ // "user" : {"value" : "ki", "boost" : 2.0 }
+ },
+
+// wildcard
+ "wildcard" : {
+ "user" : "ki*y"
+
+ // or
+ //"user" : { "value" : "ki*y", "boost" : 2.0 }
+ },
+// range
+ "range" : {
+ "age" : {
+ "from" : 10,
+ "to" : 20,
+ "boost" : 2.0,
+ "_noOptimize" : false
+ }
+ },
+// filtered
+
+ "filtered" : {
+ // any query object
+ "query" : {
+ "term" : { "tag" : "wow" }
+ },
+ // any filter defined in the filters.json
+ "filter" : {
+ "range" : {
+ "age" : { "from" : 10, "to" : 20 }
+ }
+ }
+ },
+
+// terms
+ "terms" : {
+ "tags" : {
+ "values" : [ "blue", "pill" ],
+ "excludes" : ["red"],
+ "minimum_match" : 1,
+ "operator" : "or"}
+ },
+
+// span term
+ "span_term" : {
+ "color" : "red"
+
+ //or
+ // "user" : { "value" : "kimchy", "boost" : 2.0 }
+ },
+// span or
+ "span_or" : {
+ "clauses" : [
+ { "span_term" : { "field" : "value1" } },
+ { "span_term" : { "field" : "value2" } },
+ { "span_term" : { "field" : "value3" } }
+ ]
+ },
+// span not
+ "span_not" : {
+ "include" : {
+ "span_term" : { "field" : "value1" }
+ },
+ "exclude" : {
+ "span_term" : { "field" : "value2" }
+ }
+ },
+// span near
+ "span_near" : {
+ "clauses" : [
+ { "span_term" : { "field" : "value1" } },
+ { "span_term" : { "field" : "value2" } },
+ { "span_term" : { "field" : "value3" } }
+ ],
+ "slop" : 12,
+ "in_order" : false,
+ "collect_payloads" : false
+ },
+
+// span first
+ "span_first" : {
+ "match" : {
+ "span_term" : { "color" : "red" }
+ },
+ "end" : 3
+ },
+
+// custom
+ "custom" : {
+ "class" : "com.sensidb.query.TestQuery",
+ "params":{
+
+ },
+ "boost" : 2.0
+ }
+}
View
72 sensei-core/src/test/json/selections.json
@@ -0,0 +1,72 @@
+[
+ {
+ "term":{
+ "category":{
+ "value":"sedan"
+ }
+ }
+ },
+
+ {
+ "term":{
+ "color":{
+ "value":"red"
+ }
+ }
+ },
+
+ {
+ "terms":{
+ "tags":{
+ "values" : [ "mp3", "moon-roof" ],
+ "excludes" : ["leather"],
+ "operator" : "or"
+ }
+ }
+ },
+
+ {
+ "range":{
+ "year":{
+ "to":"2009", //if there is no such key (upper, or lower), it returns "*";
+ "from":"2000",
+ "include_lower":true, //by default 'include_lower' and 'include_upper' are set to true;
+ "include_upper":false
+ }
+ }
+ },
+
+ {
+ "path":{
+ "city":{
+ "value":"a/b/c",
+ "strict":false,
+ "depth":1
+ }
+ }
+ },
+
+ {
+ "custom":{
+ "network":{
+ "values":["0","1"],
+ "runtime-params":{
+ "srcId":{
+ "type":"int",
+ "values":["$member"]
+ }
+ }
+ }
+ }
+ },
+
+ {
+ "default":{
+ "color":{
+ "values":[],
+ "not":[],
+ "params":{ }
+ }
+ }
+ }
+]
View
123 sensei-core/src/test/json/sensei-request.json
@@ -0,0 +1,123 @@
+// example Sensei Request
+{
+ "query" : {
+ "query_string" : {
+ "query" : "this AND that OR thus"
+ }
+ },
+
+ // paging parameters
+
+ "size" : 10, // default to 10;
+ "from" : 0, //default to 0;
+
+ // group by parameters (currently only support group by one column)
+ "groupBy" : {
+ "columns" : ["category"],
+ "top" : 3
+ },
+
+ // filters
+ "filter" : {
+ "terms" : {
+ "tags" : {
+ "values" : [ "blue", "pill" ],
+ "excludes" : ["red"],
+ "minimum_match" : 1,
+ "operator" : "or",
+ "_noOptimize" : false
+ }
+ }
+ },
+
+ "selections" : [
+ {
+ //details of this part see the selections.json
+ "tags" : {
+ "values" : [ "blue", "pill" ],
+ "excludes" : ["red"],
+ "operator" : "or"
+ }
+ },
+ {
+ "term":{
+ },
+ },
+ ],
+
+ // facet parameters
+ "facets":{
+ "category":{
+ // maximum number of facet values to return
+ "max" : 10,
+ // minimum hit count for a given facet value
+ "minCount": 1,
+ // expand sibling facet values
+ "expand" : false,
+ // facet ordering, possible values: "hits", "val", defaults to "hits"
+ "order" : "hits"
+ }
+ },
+
+ // facet initialization parameters for runtime facets
+ "facetInit":{
+ "network" : {
+ // parameter
+ "srcId" :{
+ // parameter type, valid values are: "int","string","boolean","long","bytes","double", default: "string"
+ "type" : "int",
+ // parameter values
+ "values" : [26609850] //e.g. "$member"
+ },
+ "timeOut":{
+ "type" : "double",
+ "values" : [2.4]
+ },
+ "coldStart":{
+ "type" : "boolean",
+ "values" : [true]
+ },
+ "names":{
+ "type": "string",
+ "values":["a", "b", "c"]
+ },
+ "longId":{
+ "type": "long",
+ "values":[1234567890, 9876543210]
+ },
+ "binary":{
+ "type": "bytes",
+ "values":["SGVsbG8gd29ybGQ="]
+ }
+ }
+ },
+
+ // sort parameters
+ "sort":[
+ {"color":"desc"}, // sort by color in reverse order
+ "_score" // secondary sort by relevance, reverse parameter is ignored
+ ],
+
+
+
+ // fetch stored fields
+ "fetchStored" : false,
+
+ // fetch term vectors: array of field names
+ "termVectors" : [],
+
+ // partitions to send request to, empty list or null implies all partitions
+ "partitions":[1,2],
+
+ // send back scoring explanation for each hit
+ "explain" : false,
+
+ // routing parameter, if set, request will be consistent hashed to the same replica for each partition
+ "routeParam": null,
+
+ //Allows template substitution on the server. The template occurrence in other places should begin with the dollar sign. Even for the int values the template needs to be in quotes
+ "templateMapping":{
+ "size" : 10
+ }
+ //"size" : "$size"
+}

0 comments on commit e5521b5

Please sign in to comment.
Something went wrong with that request. Please try again.