Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Latest

on:
push:
branches:
- "master"
env:
CARGO_TERM_COLOR: always
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: nbittich/mu-search:latest
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM semtech/mu-jruby-template:3.1.0

LABEL maintainer="redpencil <[email protected]>"

RUN apt update && apt install gdal-bin -y

# 200MB
ENV MAXIMUM_FILE_SIZE="209715200"
# seconds
Expand Down
20 changes: 20 additions & 0 deletions framework/elastic_query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,26 @@ def construct_es_query_term(filter_key, value)
terms: { field => value.split(",") }
}
end
when "geo"
ensure_single_field_for flag, fields do |field|
query = value.split(",") # just for the poc
lat = query[0].to_f
lon = query[1].to_f
distance = query[2]
{
bool: {
filter: {
geo_distance: {
distance: distance,
field => {
lat: lat,
lon: lon
}
}
}
}
}
end
when "fuzzy_phrase"
ensure_single_field_for flag, fields do |field|
clauses = value.split(" ").map do |word|
Expand Down
24 changes: 23 additions & 1 deletion lib/mu_search/document_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require '/usr/src/app/sinatra_template/utils' # provided by template
require_relative './property_definition'


module MuSearch
##
# This class is responsible for building JSON documents from an IndexDefinition
Expand All @@ -12,7 +14,7 @@ def initialize(tika:, sparql_client:, attachment_path_base:, logger:)
@attachment_path_base = attachment_path_base
@cache_path_base = "/cache/"
@logger = logger
end
end

##
# Builds a document to index for the given resource URI and index_definition
Expand Down Expand Up @@ -122,6 +124,8 @@ def construct_document_to_index(uri: nil, definitions: property_definitions)

if definition.type == "simple"
index_value = build_simple_property(matching_values)
elsif definition.type == "lambert-72"
index_value = build_lambert_property(matching_values)
elsif definition.type == "language-string"
index_value = build_language_property(matching_values)
elsif definition.type == "attachment"
Expand All @@ -138,6 +142,24 @@ def construct_document_to_index(uri: nil, definitions: property_definitions)
Hash[key_value_tuples]
end

def build_lambert_property(values)
loc_map = Hash.new {|hash, key| hash[key] = 0.0}
values.collect do |value|
## assuming <http://www.opengis.net/def/crs/EPSG/0/31370> POINT(160167.27757517056 168249.60765740927)
match = value.to_s.match(/POINT\(([\d.]+)\s([\d.]+)\)/)
next unless match && match.length == 2
x_lambert = match[1].to_f
y_lambert = match[2].to_f
next unless x_lambert && y_lambert
output = `echo "#{x_lambert} #{y_lambert}" | gdaltransform -s_srs EPSG:31370 -t_srs EPSG:4326`
lon, lat, _ = output.split(' ')
next unless lon && lat
loc_map["lon"] = lon
loc_map["lat"] = lat
end
[loc_map]
end

# Get the array of values to index for a given SPARQL result set of simple values.
# Values are constructed based on the literal datatype.
def build_simple_property(values)
Expand Down
10 changes: 7 additions & 3 deletions lib/mu_search/property_definition.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module MuSearch
class PropertyDefinition
PROPERTY_TYPES = ["simple", "nested", "attachment", "language-string"]
PROPERTY_TYPES = ["simple", "nested", "attachment", "language-string", "lambert-72"]
attr_reader :name, :type, :rdf_type, :path, :pipeline, :sub_properties

def initialize(name: , path:, type: "auto", rdf_type: nil, sub_properties:)
Expand Down Expand Up @@ -29,8 +29,12 @@ def self.from_json_config(name, config)
from_json_config(subname, subconfig)
end
rdf_type = config["rdf_type"]
elsif config.key?("type") && config["type"] == "language-string"
type = "language-string"
elsif config.key?("type")
if config["type"] == "language-string"
type = "language-string"
elsif config["type"] == "lambert-72"
type = "lambert-72"
end
end
elsif config.is_a?(Array)
path = config
Expand Down