Search for array in jsonb field (address components from Google maps) - sql

I have a table events with a location_details jsonb field, sometimes empty, sometimes filled with records like this:
{
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png",
"name": "Boulevard Pershing",
"geometry": {
"location": {
"lat": 48.8805276,
"lng": 2.283755
},
"viewport": {
"east": 2.285103980291502,
"west": 2.282406019708498,
"north": 48.8818765802915,
"south": 48.8791786197085
}
},
"html_attributions": [
],
"address_components": [
{
"types": [
"route"
],
"long_name": "Boulevard Pershing",
"short_name": "Boulevard Pershing"
},
{
"types": [
"locality",
"political"
],
"long_name": "Paris",
"short_name": "Paris"
},
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Département de Paris",
"short_name": "Département de Paris"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Île-de-France",
"short_name": "IDF"
},
{
"types": [
"country",
"political"
],
"long_name": "France",
"short_name": "FR"
},
{
"types": [
"postal_code"
],
"long_name": "75017",
"short_name": "75017"
}
]
}
I would like to let users search events by location, but not by precise location (e.g. "route" in this example).
any idea on how I can do that?

I parsed the address_components so that they can be easily accessed in SQL:
{
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png",
"name": "Boulevard Pershing",
"geometry": {
"location": {
"lat": 48.8805276,
"lng": 2.283755
},
"viewport": {
"east": 2.285103980291502,
"west": 2.282406019708498,
"north": 48.8818765802915,
"south": 48.8791786197085
}
},
"html_attributions": [
],
"address_components": [
{
"types": [
"route"
],
"long_name": "Boulevard Pershing",
"short_name": "Boulevard Pershing"
},
{
"types": [
"locality",
"political"
],
"long_name": "Paris",
"short_name": "Paris"
},
{
"types": [
"administrative_area_level_2",
"political"
],
"long_name": "Département de Paris",
"short_name": "Département de Paris"
},
{
"types": [
"administrative_area_level_1",
"political"
],
"long_name": "Île-de-France",
"short_name": "IDF"
},
{
"types": [
"country",
"political"
],
"long_name": "France",
"short_name": "FR"
},
{
"types": [
"postal_code"
],
"long_name": "75017",
"short_name": "75017"
}
],
"address_components_parsed": {
"route": {
"short_name": "Boulevard Pershing",
"long_name": "Boulevard Pershing"
},
"locality": {
"short_name": "Paris",
"long_name": "Paris"
},
"political": {
"short_name": "FR",
"long_name": "France"
},
"administrative_area_level_2": {
"short_name": "Département de Paris",
"long_name": "Département de Paris"
},
"administrative_area_level_1": {
"short_name": "IDF",
"long_name": "Île-de-France"
},
"country": {
"short_name": "FR",
"long_name": "France"
},
"postal_code": {
"short_name": "75017",
"long_name": "75017"
}
}
}
revelant ruby code:
def location_details=(value)
return if value.blank?
value =
value.is_a?(String) ? JSON.parse(value.presence || "{}") : (value || {})
value["address_components_parsed"] =
address_components_for(value["address_components"])
super(value)
rescue JSON::ParserError
errors.add(:location_details, I18n.t("events.errors.is_not_valid_json"))
super(value)
end
def address_components
(location_details || {}).fetch("address_components_parsed", {})
end
def address_components_for(address_components)
(location_details || {})
.fetch("address_components", {})
.each_with_object({}) do |el, acc|
el["types"].each do |type|
acc[type] ||= {}
acc[type]["short_name"] = el["short_name"]
acc[type]["long_name"] = el["long_name"]
end
end
end

Related

Create Delivery Plan styling rules using Azure Devops REST Apis

I am trying to create Delivery plan in the Azure Devops project using Azure Devops REST Apis. I have used following method to create the same.
https://learn.microsoft.com/en-us/rest/api/azure/devops/work/plans/create?view=azure-devops-rest-6.0
POST https://dev.azure.com/{organization}/{project}/_apis/work/plans?api-version=6.0
and I am sending following data in the request body properties
{
"properties": {
"teamBacklogMappings": [
{
"teamId": "09d57738-697f-4433-abdd-b80a2bc6337b",
"categoryReferenceName": "Microsoft.RequirementCategory"
},
{
"teamId": "5df45eec-4108-474a-8d93-bc09c0b9037e",
"categoryReferenceName": "Microsoft.RequirementCategory"
},
{
"teamId": "e8ed402b-68e7-4140-96f2-07790a08788b",
"categoryReferenceName": "Microsoft.RequirementCategory"
},
{
"teamId": "14425694-efa5-454e-811c-e9e03d79198f",
"categoryReferenceName": "Microsoft.RequirementCategory"
},
{
"teamId": "b02690e9-1f48-421a-a918-3b23cc9a1b73",
"categoryReferenceName": "Microsoft.RequirementCategory"
}
],
"cardSettings": {
"fields": {
"showId": true,
"showAssignedTo": true,
"assignedToDisplayFormat": "avatarOnly",
"showState": true,
"showTags": true,
"showParent": false,
"showEmptyFields": true,
"showChildRollup": true,
"additionalFields": null,
"coreFields": [
{
"referenceName": "System.AssignedTo",
"displayName": "Assigned To",
"fieldType": "string",
"isIdentity": true
},
{
"referenceName": "System.Id",
"displayName": "ID",
"fieldType": "integer",
"isIdentity": false
},
{
"referenceName": "System.State",
"displayName": "State",
"fieldType": "string",
"isIdentity": false
},
{
"referenceName": "System.Tags",
"displayName": "Tags",
"fieldType": "plainText",
"isIdentity": false
}
]
}
},
"markers": [],
"styleSettings": [
{
"name": "BLOCKER",
"isEnabled": "True",
"filter": "[System.Tags] CONTAINS 'BLOCKER'",
"clauses": [
{
"fieldName": "System.Tags",
"logicalOperator": "AND",
"operator": "CONTAINS",
"value": "BLOCKER"
}
],
"settings": {
"background-color": "#E60017",
"title-color": "#000000"
}
},
{
"name": "New",
"isEnabled": "True",
"filter": "[System.State] = 'New'",
"clauses": [
{
"fieldName": "System.State",
"logicalOperator": "AND",
"operator": "=",
"value": "New"
}
],
"settings": {
"background-color": "#AAAAAA",
"title-color": "#000000"
}
},
{
"name": "Dev Completed",
"isEnabled": "True",
"filter": "[System.State] = 'Development Completed'",
"clauses": [
{
"fieldName": "System.State",
"logicalOperator": "AND",
"operator": "=",
"value": "Development Completed"
}
],
"settings": {
"background-color": "#D7E587",
"title-color": "#000000"
}
},
{
"name": "Deployed to QA",
"isEnabled": "True",
"filter": "[System.State] = 'Deployed to QA (SIT)'",
"clauses": [
{
"fieldName": "System.State",
"logicalOperator": "AND",
"operator": "=",
"value": "Deployed to QA (SIT)"
}
],
"settings": {
"background-color": "#C3D84C",
"title-color": "#000000"
}
},
{
"name": "Deployed to UAT",
"isEnabled": "True",
"filter": "[System.State] = 'Deployed to UAT'",
"clauses": [
{
"fieldName": "System.State",
"logicalOperator": "AND",
"operator": "=",
"value": "Deployed to UAT"
}
],
"settings": {
"background-color": "#60AF49",
"title-color": "#000000"
}
},
{
"name": "Deployed to PROD",
"isEnabled": "True",
"filter": "[System.State] = 'Completed'",
"clauses": [
{
"fieldName": "System.State",
"logicalOperator": "AND",
"operator": "=",
"value": "Completed"
}
],
"settings": {
"background-color": "#00643A",
"title-color": "#000000"
}
}
],
"tagStyleSettings": []
}
}
However Styling rules are not getting created in the project.
Got this done by using Update for the Delivery plan immediately after creating the same. Update it with same properties though you will have to add revision property to the request body.
https://learn.microsoft.com/en-us/rest/api/azure/devops/work/plans/update?view=azure-devops-rest-6.0
https://dev.azure.com/{organization}/{project}/_apis/work/plans/{id}?api-version=6.0
Create Delivery Plan doesn't accept style settings, from the UI you can notice this:
Just get the plan id and the response from the Create API and then use them in the Update API, this is the only way.

VEGA Sunburst using table based raw data

I am working on a Sunburst that would eventually take input data without a configured parent-child structure but a column based data so I employed a nest transform instead of a stratify as in the given example:
https://vega.github.io/editor/#/gist/c1eeb9142fd7f611513f5a4edf7e180e/spec.json
The problem with it, is that it generates internal nodes even if some fields are empty as long as my data object got value available for leaf nodes.
How can i transform my data to get a visual as in the following example
https://vega.github.io/editor/#/gist/112c45cfed3b9c9013ea0b63a318292f/spec.json
The idea is to "transform" the column based data into a parent, child structure in order to apply a Stratify transform.
Starting data:
{
"value": 140,
"level1": "France",
"level2": "Reins",
"level3": "Jean Monnet",
"level4": "rue 3 ",
"level5": "no",
"level6": "a level"
}
First group by all the levels or depth of the sunburst according to your value or quantity.
"transform": [
{
"type": "aggregate",
"groupby": [
"level1",
"level2",
"level3",
"level4",
"level5",
"level6"
],
"fields": [
"value"
],
"ops": [
"sum"
],
"as": [
"value"
]
}
]
Secondly, we need to have a root note for stratify, so based on available data we can transform our data as following to define our root node having level1 elements as child nodes:
{
"name": "isolatedLevel1",
"source": [
"mainData"
],
"transform": [
{
"type": "project",
"fields": [
"level1",
"currentNode",
"value"
],
"as": [
"currentNode",
"parent",
"value"
]
},
{
"type": "aggregate",
"groupby": [
"parent",
"currentNode"
],
"fields": [
"value"
],
"ops": [
"sum"
],
"as": [
"value"
]
},
{
"type": "formula",
"as": "parent",
"expr": "!isDefined(datum.parent)?'rootID':datum.parent"
},
{
"type": "project",
"fields": [
"currentNode",
"parent",
"value"
],
"as": [
"currentNode",
"parent",
"value"
]
},
{
"type": "filter",
"expr": "datum.currentNode"
}
]
},
{
"name": "rootNode",
"source": "isolatedLevel1",
"transform": [
{
"type": "project",
"fields": [
"parent",
"level2"
],
"as": [
"currentNode",
"parent"
]
},
{
"type": "aggregate",
"groupby": ["currentNode","parent"]
},
{
"type": "project",
"fields": [
"currentNode",
"parent"
],
"as": [
"currentNode",
"parent"
]
}
]
},
{
"name": "isolatedLevel1MergedWithParent",
"source": [
"isolatedLevel1",
"rootNode"
]
},
Then, the idea is to determine for the upcoming levels, the parent and child between 2 levels.
We can apply this data transform and repeat it till the last level of our data.
{
"name": "isolatedLevel2",
"source": "mainData",
"transform": [
{
"type": "project",
"fields": [
"level1",
"level2",
"value"
],
"as": [
"parent",
"currentNode",
"value"
]
},
{
"type": "aggregate",
"groupby": [
"parent",
"currentNode"
],
"fields": [
"value"
],
"ops": [
"sum"
],
"as": [
"value"
]
},
{
"type": "project",
"fields": [
"currentNode",
"parent",
"value"
],
"as": [
"currentNode",
"parent",
"value"
]
},
{
"type": "filter",
"expr": "datum.currentNode"
},
{
"type": "filter",
"expr": "datum.parent"
}
]
}
Finally, we merge all these "decomposed" transforms all together to get back our data, transformed into a parent child hierarchy, with values associated to its nodes only. This is a way to suit your data to a Stratify VEGA transform.
{
"name": "mergedlevelsFinal",
"source": [
"isolatedLevel1",
"isolatedLevel2",
"isolatedLevel3",
"isolatedLevel4",
"isolatedLevel5",
"isolatedLevel6",
"rootNode"
],
"transform": [
{
"type": "formula",
"as": "value",
"expr": "!indata('parents','parent',datum.currentNode)? datum.value:''"
}
]
}
The hard part gone, we can now apply our stratify to the transformed data as we want for our sunburst.
{
"name": "tree",
"source": [
"mergedlevelsFinal"
],
"transform": [
{
"type": "stratify",
"key": "currentNode",
"parentKey": "parent"
},
{
"type": "partition",
"field": "value",
"sort": {
"field": "value"
},
"size": [
{
"signal": "2 * PI"
},
{
"signal": "width / 3"
}
],
"as": [
"a0",
"r0",
"a1",
"r1",
"depth",
"children"
]
},
{
"type": "formula",
"expr": "!datum.children?datum.value:''",
"as": "value"
}
]
}
Full Spec Solution available here https://vega.github.io/editor/#/gist/0f66d06894b61f8ba131f13f564e8c1f/spec.json

Remove Object Using Conditional Filtering - Mule 3

I need to do a conditional filtering using Mule 3. A sample payload is given below:
{
"MainNode": {
"ID": "123",
"MainNodekey1": "1",
"sysDetail": [
{
"sysDetail11": "localhost1",
"sysDetail21": "443",
"country": [
{
"k1": "country",
"value": [
"IN"
]
}
]
},
{
"sysDetail21": "localhost2",
"sysDetail22": "443",
"country": [
{
"k2": "country",
"value": [
"RSA",
"UK",
"SL"
]
}
]
}
],
"sysDetai2": {},
"sysDetai3": {}
},
"MainCode": "AAA",
"MainTyoe": "BBB",
"MyArray": [
{
"ObjId": "100",
"Obj1": {
"SubObj11": {},
"SubObj12": {},
"ObjCountry": "IN",
"ObjId": "A100"
},
"Obj1Source": {}
},
{
"ObjId": "200",
"Obj2": {
"SubObj21": {},
"SubObj22": {},
"ObjCountry": "IN",
"ObjId": "B100"
},
"Obj2Source": {}
}
]
}
The output that I need is to filter the main payload by applying a filter like below:
payload.MainNode.sysDetail.country..value == payload.Obj1.ObjCountry (which will be constant for all array elements)
Expected output is below:
{
"MainNode": {
"ID": "123",
"MainNodekey1": "1",
"sysDetail": [
{
"sysDetail11": "localhost1",
"sysDetail21": "443",
"country": [
{
"k1": "country",
"value": [
"IN"
]
}
]
}
],
"sysDetai2": {},
"sysDetai3": {}
},
"MainCode": "AAA",
"MainTyoe": "BBB",
"MyArray": [
{
"ObjId": "100",
"Obj1": {
"SubObj11": {},
"SubObj12": {},
"ObjCountry": "IN",
"ObjId": "A100"
},
"Obj1Source": {}
},
{
"ObjId": "200",
"Obj2": {
"SubObj21": {},
"SubObj22": {},
"ObjCountry": "IN",
"ObjId": "B100"
},
"Obj2Source": {}
}
]
}

How do I use the Google Civic Information API to retrieve members of Congress for a given location?

I've tried using the civicinfo.representatives.representativeInfoByAddress endpoint in the API explorer (https://developers.google.com/apis-explorer/?hl=en_US#p/civicinfo/v2/civicinfo.representatives.representativeInfoByAddress).
Here's my problem: That endpoint returns all state, federal, and local offices EXCEPT the U.S. House of Representatives! I can see the governor, senators, state senators, but NOT members of Congress. I can't find anything in the documentation to explain why this blatantly important data is being omitted, nor can I find any alternative sources (that are actually current) for this data.
Why is Google withholding the Congressional data and how do I get it? That's the ONE THING I need from this API and it seems to be missing from the results. I've tried playing with the parameters and whatnot but I can't find that data.
There has to be a way to find this information. In the Google API Explorer (see above link), try entering "WA" for the "address" field and leave everything else blank (setting the next one to TRUE makes no difference and the others are just filters). Here's the data that's returned:
{
"kind": "civicinfo#representativeInfoResponse",
"normalizedInput": {
"line1": "",
"city": "",
"state": "WA",
"zip": ""
},
"divisions": {
"ocd-division/country:us": {
"name": "United States",
"officeIndices": [
0,
1
]
},
"ocd-division/country:us/state:wa": {
"name": "Washington",
"officeIndices": [
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
]
}
},
"offices": [
{
"name": "President of the United States",
"divisionId": "ocd-division/country:us",
"levels": [
"country"
],
"roles": [
"headOfState",
"headOfGovernment"
],
"officialIndices": [
0
]
},
{
"name": "Vice-President of the United States",
"divisionId": "ocd-division/country:us",
"levels": [
"country"
],
"roles": [
"deputyHeadOfGovernment"
],
"officialIndices": [
1
]
},
{
"name": "United States Senate",
"divisionId": "ocd-division/country:us/state:wa",
"levels": [
"country"
],
"roles": [
"legislatorUpperBody"
],
"officialIndices": [
2,
3
]
},
{
"name": "Governor",
"divisionId": "ocd-division/country:us/state:wa",
"levels": [
"administrativeArea1"
],
"roles": [
"headOfGovernment"
],
"officialIndices": [
4
]
},
{
"name": "Lieutenant Governor",
"divisionId": "ocd-division/country:us/state:wa",
"levels": [
"administrativeArea1"
],
"roles": [
"deputyHeadOfGovernment"
],
"officialIndices": [
5
]
},
{
"name": "State Auditor",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
6
]
},
{
"name": "State Treasurer",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
7
]
},
{
"name": "Attorney General",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
8
]
},
{
"name": "Secretary of State",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
9
]
},
{
"name": "Insurance Commissioner",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
10
]
},
{
"name": "Commissioner of Public Lands",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
11
]
},
{
"name": "State Superintendent of Public Instruction",
"divisionId": "ocd-division/country:us/state:wa",
"officialIndices": [
12
]
}
],
"officials": [
{
"name": "Donald J. Trump",
"address": [
{
"line1": "The White House",
"line2": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"zip": "20500"
}
],
"party": "Republican",
"phones": [
"(202) 456-1111"
],
"urls": [
"http://www.whitehouse.gov/"
],
"photoUrl": "https://www.whitehouse.gov/sites/whitehouse.gov/files/images/45/PE%20Color.jpg",
"channels": [
{
"type": "GooglePlus",
"id": "+whitehouse"
},
{
"type": "Facebook",
"id": "whitehouse"
},
{
"type": "Twitter",
"id": "potus"
},
{
"type": "YouTube",
"id": "whitehouse"
}
]
},
{
"name": "Mike Pence",
"address": [
{
"line1": "The White House",
"line2": "1600 Pennsylvania Avenue NW",
"city": "Washington",
"state": "DC",
"zip": "20500"
}
],
"party": "Republican",
"phones": [
"(202) 456-1111"
],
"urls": [
"http://www.whitehouse.gov/"
],
"photoUrl": "https://www.whitehouse.gov/sites/whitehouse.gov/files/images/45/VPE%20Color.jpg",
"channels": [
{
"type": "GooglePlus",
"id": "+whitehouse"
},
{
"type": "Facebook",
"id": "whitehouse"
},
{
"type": "Twitter",
"id": "VP"
}
]
},
{
"name": "Maria Cantwell",
"address": [
{
"line1": "511 Hart Senate Office Building",
"city": "Washington",
"state": "DC",
"zip": "20510"
}
],
"party": "Democratic",
"phones": [
"(202) 224-3441"
],
"urls": [
"https://www.cantwell.senate.gov/"
],
"photoUrl": "http://bioguide.congress.gov/bioguide/photo/C/C000127.jpg",
"channels": [
{
"type": "Facebook",
"id": "senatorcantwell"
},
{
"type": "Twitter",
"id": "senatorcantwell"
},
{
"type": "YouTube",
"id": "SenatorCantwell"
}
]
},
{
"name": "Patty Murray",
"address": [
{
"line1": "154 Russell Senate Office Building",
"city": "Washington",
"state": "DC",
"zip": "20510"
}
],
"party": "Democratic",
"phones": [
"(202) 224-2621"
],
"urls": [
"http://www.murray.senate.gov/public/"
],
"photoUrl": "http://bioguide.congress.gov/bioguide/photo/M/M001111.jpg",
"channels": [
{
"type": "GooglePlus",
"id": "+pattymurray"
},
{
"type": "Twitter",
"id": "pattymurray"
},
{
"type": "YouTube",
"id": "SenatorPattyMurray"
},
{
"type": "Facebook",
"id": "pattymurray"
},
{
"type": "YouTube",
"id": "pattymurray"
}
]
},
{
"name": "Jay Inslee",
"address": [
{
"line1": "PO Box 40002",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Democratic",
"phones": [
"(360) 902-4111"
],
"urls": [
"http://www.governor.wa.gov/"
],
"photoUrl": "http://www.governor.wa.gov/sites/default/files/images/720px-for-web_0.jpg",
"emails": [
"Governor.JayInslee#governor.wa.gov"
],
"channels": [
{
"type": "Facebook",
"id": "WaStateGov"
},
{
"type": "Twitter",
"id": "GovInslee"
},
{
"type": "YouTube",
"id": "UCJhWBqWVdVnPro7tx2t7j3w"
}
]
},
{
"name": "Cyrus Habib",
"address": [
{
"line1": "PO Box 40400",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Democratic",
"phones": [
"(360) 786-7700"
],
"urls": [
"http://www.ltgov.wa.gov/"
],
"photoUrl": "http://www.ltgov.wa.gov/wp-content/uploads/2017/01/Senator-Habib-2015_CROPPED-225x300.jpg",
"emails": [
"ltgov#ltgov.wa.gov"
],
"channels": [
{
"type": "Twitter",
"id": "waltgov"
},
{
"type": "Facebook",
"id": "Lt-Governor-Cyrus-Habib-347384975292728"
}
]
},
{
"name": "Pat (Patrice) McCarthy",
"address": [
{
"line1": "Insurance Building Capitol Campus",
"line2": "302 Sid Snyder Avenue SW",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Democratic",
"phones": [
"(360) 902-0370"
]
},
{
"name": "Duane Davidson",
"address": [
{
"line1": "PO Box 40200",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Republican",
"phones": [
"(360) 902-9001"
]
},
{
"name": "Bob Ferguson",
"address": [
{
"line1": "PO Box 40100",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Democratic",
"phones": [
"(360) 753-6200"
],
"urls": [
"http://www.atg.wa.gov/"
],
"channels": [
{
"type": "Facebook",
"id": "WAStateAttorneyGeneral"
},
{
"type": "Twitter",
"id": "AGOWA"
}
]
},
{
"name": "Kim Wyman",
"address": [
{
"line1": "PO Box 40220",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Republican",
"phones": [
"(360) 902-4151"
],
"urls": [
"http://www.sos.wa.gov/"
],
"emails": [
"kim.wyman#sos.wa.gov"
],
"channels": [
{
"type": "Facebook",
"id": "WaSecretaryOfState"
},
{
"type": "Twitter",
"id": "secstatewa"
}
]
},
{
"name": "Mike Kreidler",
"party": "Democratic",
"phones": [
"(360) 725-7000"
],
"urls": [
"http://www.insurance.wa.gov/"
],
"channels": [
{
"type": "Facebook",
"id": "wsoic"
},
{
"type": "Twitter",
"id": "WAinsuranceblog"
}
]
},
{
"name": "Hilary Franz",
"address": [
{
"line1": "PO Box 47000",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Democratic",
"phones": [
"(360) 902-1000"
]
},
{
"name": "Chris Reykdal",
"address": [
{
"line1": "Mail stop: 47200 Old Capitol Building P.O. Box 47200",
"city": "Olympia",
"state": "WA",
"zip": "98504"
}
],
"party": "Nonpartisan",
"phones": [
"(360) 725-6115"
]
}
]
}
Now, do a text search for "Adam Smith" in that JSON. He's a current member of Congress in WA. You'll notice that string is not present, nor are any other members of Congress, nor can I find any reference links in the return to look them up.
What am I missing?? It seems utterly insane to me that everything is included there except members of the U.S. House (but federal and state Senates are included). That means it's possible that the data is available somehow but I'm just not figuring it out. Can anybody help?
Thanks!
This is a couple of months late but you need to specify the to look for the roles legislatorUpperBody and legislatorLowerBody.
If you just want to have these two peices of infomation try running the query
https://www.googleapis.com/civicinfo/v2/representatives?address=[address]&levels=country&roles=legislatorUpperBody&roles=legislatorLowerBody&key=[api_key]
Instead of returning all possible results for representatives for a given area, the API seems to only return exact matches.
Assuming 2 requests that both use levels=country&roles=legislatorLowerBody.
I get 0 results using the address Boston, MA.
I get the proper representative using the address 10 Summer St, Boston, MA.
Congressional districts can be pretty specific. In some cases the street number along the same street will dictate one district versus another.

documents not auto indexing elasticsearch

I have created an elasticsearch index. It searches everything correctly but when any new document is added it does not index it automatically. Everytime I have to restart the service for it to index the new document.
PUT /_river/mydocum1/_meta
{
"type": "fs",
"fs": {
"url": "\\\\file\\datum\\Depart\\Inet\\",
"update_rate": 3600,
"includes": [
"*.docx",
"*.xlsx",
"*.pdf",
"*.txt",
"*.doc",
"*.xls"
]
},
"index": {
"index": "test",
"type": "docum",
"bulk_size": 500
}
}
EDIT:
Here are the settings
{
"test": {
"settings": {
"index": {
"uuid": "9rofjAZySByrtehnjemkjudg",
"analysis": {
"filter": {
"synonym_filter": {
"type": "synonym",
"synonyms_path": "analysis/main_synonym.txt"
},
"nGram_filter": {
"max_gram": "20",
"min_gram": "2",
"type": "nGram",
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
},
"analyzer": {
"search_analyzer_2": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"synonym_filter"
],
"tokenizer": "standard"
},
"index_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
],
"tokenizer": "whitespace"
},
"search_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"synonym_filter"
],
"tokenizer": "whitespace"
},
"index_analyzer_2": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "whitespace"
},
"index_analyzer_3": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "standard"
},
"nGram_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
],
"tokenizer": "whitespace"
},
"index_analyzer_4": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "keyword"
},
"whitespace_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"asciifolding"
],
"tokenizer": "whitespace"
}
}
}
}
}
Does anyone know how do I solve it?