In react app I need to implement ui schema.
The scheme storages in database and react app take it from there and then put it
to Form from react-jsonschema-form package, but textfield doesn't change, it's still "input" but not "textarea".
I use
"_uiSchema" : {
"content" : {
"items" : {
"text" : {
"ui:widget" : "textarea"
}
}
}
},
but text didnt chage type. And text is
"text" : {
"type" : "string"
},
And full Schema
{
"title" : "Career",
"type" : "object",
"properties" : {
"_id" : {
"type" : "string",
"title" : "_id"
},
"urlPage" : {
"type" : "string",
"title" : "url"
},
"subUrls" : {
"type" : "array",
"title" : "Sub urls",
"items" : {
"type" : "string"
}
},
"content" : {
"type" : "array",
"title" : "page",
"items" : [
{
"title" : "content",
"type" : "object",
"properties" : {
"categoryTitle" : {
"type" : "string",
"title" : "Category title"
},
"popUp" : {
"type" : "object",
"properties" : {
"successSubTitle" : {
"type" : "string"
},
"successTitle" : {
"type" : "string"
},
"subTitlePopUp" : {
"type" : "string"
},
"titlePopUp" : {
"type" : "string"
}
}
},
"categorySubTitle" : {
"type" : "string",
"title" : "Category sub title"
},
"tabs" : {
"type" : "array",
"title" : "Tabs",
"items" : {
"type" : "object",
"properties" : {
"path" : {
"type" : "string"
},
"title" : {
"type" : "string"
}
}
}
},
"notFindMessage" : {
"type" : "string"
},
"data" : {
"title" : "Open positions",
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"category" : {
"type" : "string"
},
"summary" : {
"type" : "string"
},
"details" : {
"type" : "array",
"items" : {
"type" : "object",
"properties" : {
"sectionTitle" : {
"type" : "string"
},
//here is my text field
"text" : {
"type" : "string"
},
"listItems" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
}
}
}
}
}
}
}
]
}
}
}
I read guide on te github (https://github.com/mozilla-services/react-jsonschema-form#the-uischema-object)
UPDATE
ui schema that works
"content" : {
"items" : {
"data" : {
"items" : {
"details" : {
"items" : {
"myText" : {
"ui:widget" : "textarea"
}
}
}
}
}
}
}
I have checked the source code of this library and seems like you have to have description for items in uiSchema.
"_uiSchema" : {
"content" : {
"items" : {
"description" : {
"ui:widget" : "textarea"
}
}
}
}
Related
[PS : I have gone through all the possible issues under same error and tried to fix my Json Schema]
I have the following Avro Schema (Converted to JSON using http://json-schema-validator.herokuapp.com/avro.jsp) :
{
"definitions" : {
"record:parentTest.test.MyPlatformData" : {
"description" : "representsthetestevent",
"type" : "object",
"required" : [ "event", "subjects" ],
"additionalProperties" : false,
"properties" : {
"event" : {
"$ref" : "#/definitions/record:parentTest.test.event_record"
},
"subjects" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/record:parentTest.test.TESTEVENT_record"
}
}
}
},
"record:parentTest.test.event_record" : {
"type" : "object",
"required" : [ "created_at", "id", "event_at", "subject", "action", "up_event_id", "up_source" ],
"additionalProperties" : false,
"properties" : {
"created_at" : {
"type" : "string"
},
"id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
},
"event_at" : {
"type" : "string"
},
"subject" : {
"type" : "string"
},
"action" : {
"type" : "string"
},
"up_event_id" : {
"default" : "null",
"oneOf" : [ {
"type" : "string"
}, {
"type" : "null"
} ]
},
"up_source" : {
"default" : "null",
"oneOf" : [ {
"type" : "string"
}, {
"type" : "null"
} ]
}
}
},
"record:parentTest.test.TESTEVENT_record" : {
"type" : "object",
"required" : [ "mydata", "id", "user_id", "data_id", "place_id", "my_object" ],
"additionalProperties" : false,
"properties" : {
"mydata" : {
"$ref" : "#/definitions/record:parentTest.test.mydata_record"
},
"id" : {
"type" : "integer",
"minimum" : -9223372036854775808,
"maximum" : 9223372036854775807
},
"user_id" : {
"type" : "integer",
"minimum" : -9223372036854775808,
"maximum" : 9223372036854775807
},
"data_id" : {
"type" : "integer",
"minimum" : -9223372036854775808,
"maximum" : 9223372036854775807
},
"place_id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
},
"my_object" : {
"$ref" : "#/definitions/record:parentTest.test.my_object_record"
}
}
},
"record:parentTest.test.mydata_record" : {
"type" : "object",
"required" : [ "id", "del" ],
"additionalProperties" : false,
"properties" : {
"id" : {
"type" : "integer",
"minimum" : -9223372036854775808,
"maximum" : 9223372036854775807
},
"del" : {
"$ref" : "#/definitions/record:parentTest.test.del_record"
}
}
},
"record:parentTest.test.del_record" : {
"type" : "object",
"required" : [ "status", "track_details", "cr", "service_level" ],
"additionalProperties" : false,
"properties" : {
"status" : {
"$ref" : "#/definitions/record:parentTest.test.status_record"
},
"tracking_details" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/record:parentTest.test.tracking_number_detail_record"
}
},
"cr" : {
"$ref" : "#/definitions/record:parentTest.test.cr_record"
},
"service_level" : {
"$ref" : "#/definitions/record:parentTest.test.service_level_record"
}
}
},
"record:parentTest.test.status_record" : {
"type" : "object",
"required" : [ "name", "status_at" ],
"additionalProperties" : false,
"properties" : {
"name" : {
"type" : "string"
},
"status_at" : {
"type" : "string"
}
}
},
"record:parentTest.test.tracking_number_detail_record" : {
"type" : "object",
"required" : [ "id", "cr", "status" ],
"additionalProperties" : false,
"properties" : {
"id" : {
"type" : "string"
},
"cr" : {
"$ref" : "#/definitions/record:parentTest.test.tracking_cr_record"
},
"status" : {
"$ref" : "#/definitions/record:parentTest.test.trac_status_record"
}
}
},
"record:parentTest.test.tracking_cr_record" : {
"type" : "object",
"required" : [ "id" ],
"additionalProperties" : false,
"properties" : {
"id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
}
}
},
"record:parentTest.test.tracking_status_record" : {
"type" : "object",
"required" : [ "name", "status_at" ],
"additionalProperties" : false,
"properties" : {
"name" : {
"oneOf" : [ {
"type" : "string"
}, {
"type" : "null"
} ]
},
"status_at" : {
"oneOf" : [ {
"type" : "string"
}, {
"type" : "null"
} ]
}
}
},
"record:parentTest.test.cr_record" : {
"type" : "object",
"required" : [ "id" ],
"additionalProperties" : false,
"properties" : {
"id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
}
}
},
"record:parentTest.test.service_level_record" : {
"type" : "object",
"required" : [ "sc_id", "ss_id", "ss_class" ],
"additionalProperties" : false,
"properties" : {
"sc_id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
},
"ss_id" : {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
},
"ss_class" : {
"type" : "string"
}
}
},
"record:parentTest.test.mydata_record" : {
"type" : "object",
"required" : [ "s_id" ],
"additionalProperties" : false,
"properties" : {
"s_id" : {
"oneOf" : [ {
"type" : "integer",
"minimum" : -2147483648,
"maximum" : 2147483647
}, {
"type" : "null"
} ]
}
}
}
},
"$ref" : "#/definitions/record:parentTest.test.MyPlatformData"
}
However on inserting the following data, I get following error
Input Data
{
"event": {
"action": "TESTEVENT",
"created_at": "2021-01-21T14:16:23+00:00",
"event_at": "2021-01-21T14:16:23.747",
"id": 28001755,
"subject": "TEST_ITEM",
"up_source": {
"string": "TEST_W"
},
"up_event_id": {
"string": "59c7eec8-9bf6-4907-9df9-628d92abd278"
}
},
"subjects": [
{
"id": 12345678,
"user_id": 5197509841,
"data_id": 3497218791,
"place_id": 49,
"mydata": {
"s_id": {
"int": 29489
}
},
"my_object": {
"id": 5417499011,
"del": {
"status": {
"name": "TESTEVENT",
"status_at": "2021-01-21T09:09:00"
},
"tracking_details": [
{
"id": "CS303755237",
"cr": {
"id": 961
},
"status": {
"name": {
"string": "TESTEVENT"
},
"status_at": {
"string": "2021-01-21T09:09:00"
}
}
}
],
"cr": {
"id": 961
},
"service_level": {
"sc_id": 2,
"ss_id": 5,
"ss_class": "MY_TEST_SS"
}
}
}
}
]
}
Error
Caused by: org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_NUMBER_INT
I was able to finally find the issue.
Being a beginner, I wasn't able to comprehend that time.
For anyone facing similar issue :
Rule : Whenever a field is marked "datatype" and "null" both, it is
important to mention the datatype, if the value is not null.
For example :
For Avro schema, field definition :
"up_source" : {
"default" : "null",
"oneOf" : [ {
"type" : "string"
}, {
"type" : "null"
} ]
}
Possible declarations :
"up_source": {
"string": "TEST_123"
},
OR
"up_source": null,
One of my fields was missing this.
I am trying to filter based on the cluster field and whether the podName field has a value.
Then I want to filter out some fields with specific values but I get the values for other cluster fields than the one specified.
So the following query will also return values for cluster2 and cluster3.
I can't figure out what the correct syntax is.
{
"size":50,
"query":{
"bool":{
"must":[
{
"range":{
"timestamp":{
"gte":"now-1h"
}
}
},
{
"query_string":{
"query":"(podstatus.podName:* AND cluster:cluster1) AND NOT podstatus.containerStatus:true AND NOT podstatus.phase:Running AND NOT podstatus.phase:Succeeded AND NOT podstatus.started: true"
}
}
]
}
}
}
Sample document
{
"timestamp": "2020-07-09T17:30:04",
"cluster": "cluster1",
"namespace": "kube-system",
"podstatus.podName": "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus": "false",
"podstatus.restartCount": 0,
"podstatus.started": "false",
"podstatus.phase": "Succeeded"
}
Mapping
{
"cluster-resources-cluster1-2020.07.08-000001" : {
"mappings" : {
"properties" : {
"allocated" : {
"properties" : {
"pods-percent" : {
"type" : "float"
}
}
},
"capacity" : {
"properties" : {
"cpu" : {
"type" : "long"
},
"mem" : {
"type" : "long"
},
"pods" : {
"type" : "long"
}
}
},
"cluster" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"depstatus" : {
"properties" : {
"availableReplicas" : {
"type" : "long"
},
"deploymentName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"readyReplicas" : {
"type" : "long"
},
"replicas" : {
"type" : "long"
},
"unavailableReplicas" : {
"type" : "long"
},
"updatedReplicas" : {
"type" : "long"
}
}
},
"namespace" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"podstatus" : {
"properties" : {
"containerStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"phase" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"podName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"restartCount" : {
"type" : "long"
},
"started" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"requests" : {
"properties" : {
"cpu" : {
"type" : "long"
},
"cpu-percent" : {
"type" : "float"
},
"mem" : {
"type" : "long"
},
"mem-percent" : {
"type" : "float"
},
"pods" : {
"type" : "long"
}
}
},
"timestamp" : {
"type" : "date"
}
}
}
}
}
Your query seems to be working correctly. However I'm posting the below steps and you let me know if you can find any observations in similar manner.
I've taken the mapping, created sample documents, the query you've shared and response I get.
Mapping:
PUT cluster_index_001
{
"mappings" : {
"properties" : {
"allocated" : {
"properties" : {
"pods-percent" : {
"type" : "float"
}
}
},
"capacity" : {
"properties" : {
"cpu" : {
"type" : "long"
},
"mem" : {
"type" : "long"
},
"pods" : {
"type" : "long"
}
}
},
"cluster" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"depstatus" : {
"properties" : {
"availableReplicas" : {
"type" : "long"
},
"deploymentName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"readyReplicas" : {
"type" : "long"
},
"replicas" : {
"type" : "long"
},
"unavailableReplicas" : {
"type" : "long"
},
"updatedReplicas" : {
"type" : "long"
}
}
},
"namespace" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"podstatus" : {
"properties" : {
"containerStatus" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"phase" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"podName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"restartCount" : {
"type" : "long"
},
"started" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"requests" : {
"properties" : {
"cpu" : {
"type" : "long"
},
"cpu-percent" : {
"type" : "float"
},
"mem" : {
"type" : "long"
},
"mem-percent" : {
"type" : "float"
},
"pods" : {
"type" : "long"
}
}
},
"timestamp" : {
"type" : "date"
}
}
}
}
Sample Documents:
POST cluster_index_001/_doc/1
{
"timestamp": "2020-07-09T17:30:04",
"cluster": "cluster1",
"namespace": "kube-system",
"podstatus.podName": "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus": "false",
"podstatus.restartCount": 0,
"podstatus.started": "false",
"podstatus.phase": "Failed"
}
POST cluster_index_001/_doc/2
{
"timestamp": "2020-07-10T17:30:04",
"cluster": "cluster1",
"namespace": "kube-system",
"podstatus.podName": "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus": "false",
"podstatus.restartCount": 0,
"podstatus.started": "false",
"podstatus.phase": "Failed"
}
POST cluster_index_001/_doc/3
{
"timestamp": "2020-07-10T17:30:04",
"cluster": "cluster2",
"namespace": "kube-system",
"podstatus.podName": "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus": "false",
"podstatus.restartCount": 0,
"podstatus.started": "false",
"podstatus.phase": "Failed"
}
Sample Query:
POST cluster_index_001/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"gte": "now-2d"
}
}
},
{
"query_string": {
"query":"(podstatus.podName:* AND cluster:cluster1) AND NOT podstatus.containerStatus:true AND NOT podstatus.phase:Running AND NOT podstatus.phase:Succeeded AND NOT podstatus.started:true"
}
}
]
}
}
}
You could also make use of cluster.keyword in the above like this cluster.keyword:cluster1 for exact matches.
Response:
{
"took" : 86,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 2.4700036,
"hits" : [
{
"_index" : "cluster_index_001",
"_type" : "_doc",
"_id" : "1",
"_score" : 2.4700036,
"_source" : {
"timestamp" : "2020-07-09T17:30:04",
"cluster" : "cluster1",
"namespace" : "kube-system",
"podstatus.podName" : "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus" : "false",
"podstatus.restartCount" : 0,
"podstatus.started" : "false",
"podstatus.phase" : "Failed"
}
},
{
"_index" : "cluster_index_001",
"_type" : "_doc",
"_id" : "2",
"_score" : 2.4700036,
"_source" : {
"timestamp" : "2020-07-10T17:30:04",
"cluster" : "cluster1",
"namespace" : "kube-system",
"podstatus.podName" : "cronjob-kubernetes-resource-monitor-1594233600-4frbc",
"podstatus.containerStatus" : "false",
"podstatus.restartCount" : 0,
"podstatus.started" : "false",
"podstatus.phase" : "Failed"
}
}
]
}
}
Note that query works correctly and returns correct set of documents
Additional Debugging and Further Info:
This steps would help you verify and let you know why the document that was not supposed to be returned is returning.
For e.g the 3rd Document in the sample was not showing up in the response for me, and the way to figure out that is to make use of Explain API.
GET cluster_index_001/_explain/3 <----- Note this
{
"query": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"gte": "now-2d"
}
}
},
{
"query_string": {
"query":"podstatus.podName:* AND cluster:cluster1 AND NOT podstatus.containerStatus:true AND NOT podstatus.phase:Running AND NOT podstatus.started: true"
}
}
]
}
}
}
The response for which I see is the below:
{
"_index" : "cluster_index_001",
"_type" : "_doc",
"_id" : "3",
"matched" : false,
"explanation" : {
"value" : 0.0,
"description" : "Failure to meet condition(s) of required/prohibited clause(s)",
"details" : [
{
"value" : 1.0,
"description" : "ConstantScore(DocValuesFieldExistsQuery [field=timestamp])",
"details" : [ ]
},
{
"value" : 0.0,
"description" : "no match on required clause (+ConstantScore(NormsFieldExistsQuery [field=podstatus.podName]) +cluster:cluster1 -podstatus.containerStatus:true -podstatus.phase:running -podstatus.started:true)",
"details" : [
{
"value" : 0.0,
"description" : "Failure to meet condition(s) of required/prohibited clause(s)",
"details" : [
{
"value" : 1.0,
"description" : "ConstantScore(NormsFieldExistsQuery [field=podstatus.podName])",
"details" : [ ]
},
{
"value" : 0.0,
"description" : "no match on required clause (cluster:cluster1)",
"details" : [
{
"value" : 0.0,
"description" : "no matching term",
"details" : [ ]
}
]
}
]
}
]
}
]
}
}
Note how the description in the above response clearly states this:
"description" : "Failure to meet condition(s) of required/prohibited clause(s)"
Also note the below:
"description" : "no match on required clause (+ConstantScore(NormsFieldExistsQuery [field=podstatus.podName]) +cluster:cluster1 -podstatus.containerStatus:true -podstatus.phase:running -podstatus.started:true)",
As a result, you know now why document 3 is not returning in the response.
Further if you still are not able to figure out the issue, make sure of the below points:
Make sure you are not using any alias and that you focus on single index at a time. Narrow down the index which can be causing this issue if you are using alias.
Also make sure that your that document in question does not have multiple values for e.g. "cluster": "cluster2, cluster1"
If the above two points are clear, go to your browser and type http://<your_host_name>:<port>/cluster-resources-cluster1-2020.07.08-000001/_settings and observe if there are any custom analyzers that has been implemented for e.g. Edge Ngrams or Ngrams and if your standard analyzer has been over-ridden.
Execute this http://<your_host_name>:<port>/cluster-resources-cluster1-2020.07.08-000001/_stats?pretty and notice if you find anything peculiar.
One thing at a time, please do share your observations and we can see what is the issue.
I am trying to validate this specific schema:
{
"messages": [
{
"name": "test msg",
"id": "0x100",
"signals": {
"0": {"name": "Engine RPM", "bit_length": 16},
"16": {"name": "Gear", "bit_length": 3},
"19": {"name": "Battery Voltage", "bit_length": 5}
}
}
]
}
I am using the python from jsonschema import Draft4Validator to validate this schema... however I am not sure how to continue.
This is my current schema validation so far:
{
"$schema" : "https://json-schema.org/schema#",
"type" : "object",
"properties" :
{
"messages" :
{
"type" : "array",
"items" :
{
"properties" :
{
"name" :
{
"type" : "string"
},
"id" :
{
"type" : "string"
},
"signals" :
{
"type" : "object"
},
"properties" :
{
}
},
"required": ["name", "id", "signals"]
}
}
}
}
The problem I am facing is I am not sure how to deal with the objects that are in the "signals" key as they start with a string and are NOT consistent ("0", "16", "19")... How could I go about validating this by ensuring the type is always a string, disregarding whether or not the string is consistent.
Thanks to all of those who reply in advance.
I was able to accomplish this by doing the following:
{
"$schema" : "https://json-schema.org/schema#",
"type" : "object",
"properties" :
{
"messages" :
{
"type" : "array",
"items" :
{
"properties" :
{
"name" :
{
"type" : "string"
},
"id" :
{
"type" : "string"
},
"signals" :
{
"type" : "object"
},
"properties" :
{
"start_bit" :
{
"type" : "object",
"properties" :
{
"name" :
{
"type" : "string"
},
"bit_length" :
{
"type" : "string"
},
"factor" :
{
"type" : "string"
},
"offset" :
{
"type" : "string"
}
},
"required" : ["name", "bit_length", "factor", "offset"]
}
}
},
"required": ["name", "id", "signals"]
}
}
}
}
To "avoid" having to keep the string consistent, in the validator file, I can put any string (obviously it makes more sense to name the string what is represents, in my case "start_bit") and then by NOT having it be required.
I'm new to Elasticsearch and I have the following question about parameter comparison at filter/query:
In SQL I have something like the code below, where I compare a SQL value with a parameter value and the parameter value with a fixed value
WHERE (customer.id = :customer_id OR :customer_id = '111')
The left part of the OR above is ok, but how I compare the right part?
{ "bool": {
"should": [
{ "term":
{ "customer.id": "#customer_id" }
},
{
????
}
]
}}
Thanks in advance.
UPDATE
The mapping:
{
"_id" : {
"store" : true,
"index" : "not_analyzed"
},
"_timestamp" : {
"enabled" : true,
"store" : true
},
"properties" : {
...
"processDefinition.id" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"processDefinition.key" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"processDefinition.name" : {
"type" : "string"
},
"variables" : {
"type" : "nested",
"properties" : {
...
"executionId" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"id" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"name" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"originalType" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"rawValue" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"storedType" : {
"type" : "string",
"index" : "not_analyzed",
"doc_values" : true
},
"stringValue" : {
"type" : "string"
}
}
}
}
}
I want every "variables.rawValue": "#parameter" OR "#parameter": "ABC". Keep in mind that if #parameter is equals to "a", then the filter returns only info related to "a". If #parameter is equals to "ABC", then the filter returns info related to everything, because company ABC is owner of everything sub company (like "a). I can have a user from "a" using the filter or a user from "ABC".
I tried this:
"bool": {
"should": {
"terms": {
"variables.rawValue": [
"#currentUser_company",
"ABC"
]
}
}
}
But the filter join the result from "a" with "ABC".
One last thing. The ES version is 1.7.
Have you tried this:
{
"query": {
"bool": {
"should": [
{
"terms": {
"FIELD": [
"#customer_id",
"111"
]
}
}
]
}
}
}
#customer_id is the value which user passes
The following schema and document validate just fine even though the last line of the document uses "none" as a value which is not in the enum.
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"title" : "Test schema",
"definitions" : {
"xxx_type" : {
"enum" : [ "X1", "X2", "X3" ]
},
"xxx_info" : {
"type" : "object",
"properties" : {
"date" : { "type" : "string" },
"category" : {
"type" : "array",
"items" : { "$ref" : "#/definitions/xxx_type" }
}
},
"required" : [ "date", "category" ]
}
},
"XXX" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/xxx_info"
}
}
}
{
"XXX" : [ { "date" : "2015/01/01", "category" : [ "X1" ] },
{ "date" : "2015/02/01", "category" : [ "X2" ] },
{ "date" : "2015/03/01", "category" : [ "X3" ] }
{ "date" : "2015/04/01", "category" : [ "none" ] }
]
}
The following says invalid. (The two lines before the "XXX" definition are the only real difference.) Here the "none" is invalid.
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"title" : "Test schema",
"definitions" : {
"xxx_type" : {
"enum" : [ "X1", "X2", "X3" ]
},
"xxx_info" : {
"type" : "object",
"properties" : {
"date" : { "type" : "string" },
"category" : {
"type" : "array",
"items" : { "$ref" : "#/definitions/xxx_type" }
}
},
"required" : [ "date", "category" ]
}
},
"type" : "object",
"properties" : {
"XXX" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/xxx_info"
}
}
}
}
{
"XXX" : [ { "date" : "2015/01/01", "category" : [ "X1" ] },
{ "date" : "2015/02/01", "category" : [ "X2" ] },
{ "date" : "2015/03/01", "category" : [ "X3" ] }
{ "date" : "2015/04/01", "category" : [ "none" ] }
]
}
The first one says it is valid because it does not validate the xxx property.
But on the second one you have changed the jsonSchema to meet the JSON document and this time it is validating the xxx property using the jsonSchema and the property is invalid because it contains an invalid node the one with the category "none"