Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Gvsd 7703 #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
88 changes: 87 additions & 1 deletion elasticsearch_app/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,42 @@ def prepare_has_time(resource):
return False


def prepare_license(resource):
if resource.license and resource.license.name:
return resource.license.name
else:
return None


def prepare_classification(layer):
if layer.service and layer.service.classification:
return layer.service.classification
else:
return None


def prepare_caveat(layer):
if layer.service and layer.service.caveat:
return layer.service.caveat
else:
return None


def prepare_provenance(layer):
if layer.service and layer.service.provenance:
return layer.service.provenance
else:
return None


def prepare_poc_name(layer):
if layer.exchangelayer and layer.exchangelayer.exchange_service and \
layer.exchangelayer.exchange_service.poc_name:
return layer.exchangelayer.exchange_service.poc_name
else:
return None


class LayerIndex(DocType):
id = Integer()
abstract = Text(
Expand Down Expand Up @@ -277,6 +313,37 @@ class LayerIndex(DocType):
num_comments = Integer()
geogig_link = Keyword()
has_time = Boolean()
license = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)
classification = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)
caveat = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)
provenance = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)
poc_name = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)


class Meta:
index = 'layer-index'
Expand Down Expand Up @@ -324,7 +391,12 @@ def create_layer_index(layer):
geogig_link=layer.geogig_link,
has_time=prepare_has_time(layer),
references=prepare_references(layer),
source_host=prepare_source_host(layer)
source_host=prepare_source_host(layer),
license=prepare_license(layer),
classification=prepare_classification(layer),
caveat=prepare_caveat(layer),
provenance=prepare_provenance(layer),
poc_name=prepare_poc_name(layer),
)
obj.save()
return obj.to_dict(include_meta=True)
Expand Down Expand Up @@ -394,6 +466,12 @@ class MapIndex(DocType):
)
num_ratings = Integer()
num_comments = Integer()
license = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)

class Meta:
index = 'map-index'
Expand Down Expand Up @@ -432,6 +510,7 @@ def create_map_index(map):
regions=map.region_name_list(),
num_ratings=prepare_num_ratings(map),
num_comments=prepare_num_comments(map),
license=prepare_license(map),
)
obj.save()
return obj.to_dict(include_meta=True)
Expand Down Expand Up @@ -501,6 +580,12 @@ class DocumentIndex(DocType):
)
num_ratings = Integer()
num_comments = Integer()
license = Keyword(
fields={
'text': field.Text(),
'english': field.Text(analyzer='english')
}
)

class Meta:
index = 'document-index'
Expand Down Expand Up @@ -539,6 +624,7 @@ def create_document_index(document):
regions=document.region_name_list(),
num_ratings=prepare_num_ratings(document),
num_comments=prepare_num_comments(document),
license=prepare_license(document),
)
obj.save()
return obj.to_dict(include_meta=True)
Expand Down
21 changes: 18 additions & 3 deletions elasticsearch_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def get_facet_settings():
'type': {'open': True, 'display': 'Type'},
'subtype': {'open': True, 'display': 'Data Type'},
'keywords': {'show': True},
'references.scheme': {'show': True, 'display': 'Service Type'}
'references.scheme': {'show': True, 'display': 'Service Type'},
'license': {'show:': True, 'display': 'License'},
'classification': {'show:': True, 'display': 'Classification'},
'caveat': {'show:': True, 'display': 'Caveat'},
'provenance': {'show:': True, 'display': 'Provenance'},
'poc_name': {'show:': True, 'display': 'PoC Name'}
}

if additional_facets:
Expand Down Expand Up @@ -163,7 +168,12 @@ def get_facet_fields():
'keywords',
'category',
'source_host',
'references.scheme'
'references.scheme',
'license',
'classification',
'caveat',
'provenance',
'poc_name'
]

if additional_facets:
Expand Down Expand Up @@ -264,7 +274,12 @@ def get_main_query(search, query):
'type.text',
'type.english',
'references.scheme.text',
'references.scheme.pattern'
'references.scheme.pattern',
'license.english',
'classification.english',
'caveat.english',
'provenance.english',
'poc_name.english'
]

# Build main query to search in fields[]
Expand Down