Skip to content

Instantly share code, notes, and snippets.

@aj7
aj7 / ES-geometry-issues-example
Last active July 27, 2017 13:07
ES-geometry-issues-example
--- creating the index
curl -XPUT 'http://127.0.01:9200/speedlimit/'
--- adding the mapping with geo_shape
curl -XPUT '127.0.01:9200/speedlimit/_mapping/speedlimit' --data @mapping_mod.json
Mapping file:
https://www.dropbox.com/s/h0hw4k6eonfj5wy/mapping_mod.json?dl=0
(I have added quadtree and precision just to see if it makes any difference, but can remove those from the mapping_mod.json)
@aj7
aj7 / ES-geometry-indexing-issues
Created July 27, 2017 12:45
Errors with indexing geo_shapes / geometry in ES
[DEBUG][o.e.a.b.TransportShardBulkAction] [ackbar-node-1] [speedlimit][0] failed to execute bulk item (index) BulkShardRequest [[speedlimit][0]] containing [3] requests
org.elasticsearch.index.mapper.MapperParsingException: failed to parse [geometry]
at org.elasticsearch.index.mapper.GeoShapeFieldMapper.parse(GeoShapeFieldMapper.java:473) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:450) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:467) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:383) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:373) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:93) ~[elasticsearch-5.4.1.jar:5.4.1]
at org.elasticsearc
@aj7
aj7 / gist:4001325
Created November 2, 2012 13:17
searching for loxodonta africana
Started POST "/search/external" for 127.0.0.1 at 2012-11-02 13:16:23 +0000
Processing by ResultsController#external as HTML
Parameters: {"text"=>"loxodonta africana", "mode"=>"", "x"=>"9", "y"=>"13"}
Redirected to http://localhost:3000/search
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
SESSION SEARCH : #<Search:0x007fdd82489470>
Started GET "/search" for 127.0.0.1 at 2012-11-02 13:16:23 +0000
Processing by ResultsController#index as HTML
@aj7
aj7 / gist:4001174
Created November 2, 2012 12:47
error loading website
Started GET "/" for 127.0.0.1 at 2012-11-02 12:45:56 +0000
Processing by WelcomeController#index as */*
Rendered welcome/index.html.slim within layouts/application (1.9ms)
Rendered layouts/_login_links.html.slim (0.5ms)
Rendered layouts/_headers.html.slim (14.3ms)
The option: follow_location is invalid.
Completed 500 Internal Server Error in 24ms
ActionView::Template::Error (The option: follow_location is invalid.):
5: - override_remote_layout '#breadcrumb' => (render :partial => 'layouts/crumbs')
@aj7
aj7 / gist:3609208
Created September 3, 2012 13:05
The Rolex campaigns
The header information:
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
@aj7
aj7 / gist:2819746
Created May 28, 2012 15:27
Tables prepared for the RedList 2012.1 update
The tables that I have created so far are (They are all in the PUBLIC schema):
- st_all_taxa_criteria_by_region - everything by region (Global =1 )
- st_all_taxa_criteria_by_region_petition - contains a field for petition (for future use)
- st_all_taxa_criteria_by_region_pextinct_pew - contains also the Possible Extinct and PEW
- st_all_taxa_criteria_regions_ws_date_systems - all assessments by date and also systems and working sets.
- st_countryoccurrence - country occurrence information
- st_faooccurrence - all occurrence information
- st_habitats_all - all habitat information
- st_only_subpopulations - only subpopulations
- st_threats_all - all threats (I have removed this table now and instead created another one called st_threats_unknown_nothreats which basically shows the ones where people have ticked unknown or no_threats when a threat was selected - I will need to spend some more time thinking of a better way to merge the threat data together)
@aj7
aj7 / gist:2819711
Created May 28, 2012 15:21
Putting queries together for the Update
-- Pulling the FAO data together
SELECT FAO.taxonid, FAO.assessmentid, FAO.value, FAO.recordid,
record."CODE" as code, record."DESCRIPTION" as FAO, pres."LABEL" as presence,
origin."LABEL" as origin
FROM st_faooccurrencesubfield_faooccurrencelookup FAO
JOIN lookups."FAOOCCURRENCELOOKUP" record ON record."ID" = FAO.value
LEFT JOIN st_faooccurrencesubfield_presence f_pres ON FAO.recordid = f_pres.recordid
@aj7
aj7 / gist:2006921
Created March 9, 2012 15:14
Bug in save/export on Redlist website
Since the beginning of the week, I am having difficulties to save and export researches made on your website.
The research works, but when I try to save it, I get the following message : "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly."
I tried to delete all my previous saved searches to make some "room" but it did not make any difference.
I was wondering if it was possible for you to either tell me if there is anything I can do to fix the problem or if you could send me the data that I am trying to export.
I am looking the list of species suffering from given threats.
The taxa are (Animalia/Chordata/Actinopterygii/Perciformes) Chaetodontidae & Labridae & Pomacanthidae & Scaridae & Serranidae.
The different searches are:
- Species within those taxa suffering from 8.1. Invasive non-native/alien species (IUCN search criteria)
- Species within those taxa suffering from 5. Biological resource use (IUCN search criteria)
padrino g admin
=> Problem loading ./config/boot.rb
=> no such file to load -- postgres
----this is the database.rb---
ActiveRecord::Base.configurations[:development] = {
:adapter => 'postgresql',
:database => "sample_blog_development",
:username => 'root',
:password => '',
<% if (@key == "ranks") %>
[<% @json.each_with_index do |element,i| %>
{
"attr":{"id":"taxon_<%= element.name %>", "class" : "bigger"},
"data":{
"title" : "<%=h element.name %>",
"icon" : "<%= Rank.find_all_by_name(element.name).first.taxon_concepts.empty? ? "/images/icons/page.png" : "test" %>"
},
"state": "closed"
}<%= "," if i < (@json.size - 1) %>