Skip to content

Commit

Permalink
Search / Add scoring function support (with experimental config).
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Jul 25, 2019
1 parent 326c436 commit ff184e9
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,11 @@ private void addFilterToQuery(ServiceContext context,
// objectNodeQuery.set("filter", nodeFilter);
// ((ObjectNode) esQuery).set("query", objectNodeQuery);
// } else
if (queryNode.get("bool") != null) {
if (queryNode.get("function_score") != null) {
// Add filter node to the bool element of the query if provided
ObjectNode objectNode = (ObjectNode) queryNode.get("function_score").get("query").get("bool");
objectNode.set("filter", nodeFilter);
} else if (queryNode.get("bool") != null) {
// Add filter node to the bool element of the query if provided
ObjectNode objectNode = (ObjectNode) queryNode.get("bool");
objectNode.set("filter", nodeFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@

module.service('gnESFacet', ['gnGlobalSettings', 'gnTreeFromSlash', function(gnGlobalSettings, gnTreeFromSlash) {

var defaultSource = {
includes: [
'uuid',
'id',
'creat*',
'group*',
'logo',
'category',
'topicCat',
'inspire*',
'resource*',
'draft',
'overview.*',
'owner*',
'link*',
'image*',
'status*',
'rating',
'tag*',
'geom',
'isTemplate',
'valid',
'isHarvested',
'documentStandard'
]};
this.configs = {
search: {
facets: gnGlobalSettings.gnCfg.mods.search.facetConfig,
source: {
includes: [
'uuid',
'id',
'creat*',
'group*',
'logo',
'category',
'topicCat',
'inspire*',
'resource*',
'draft',
'overview.*',
'owner*',
'link*',
'image*',
'status*',
'rating',
'tag*',
'geom',
'isTemplate',
'valid',
'isHarvested',
'documentStandard'
]
}
source: defaultSource
},
home: {
facets: gnGlobalSettings.gnCfg.mods.home.facetConfig,
Expand All @@ -77,7 +77,7 @@
},
editor: {
facets: gnGlobalSettings.gnCfg.mods.editor.facetConfig,
source: {}
source: defaultSource
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,46 @@
this.convertLuceneParams = function(p, searchState) {
var params = {};
var luceneQueryString = gnEsLuceneQueryParser.facetsToLuceneQuery(searchState.filters);
// var query = {
// "function_score": {
// "query": {
// bool: {
// must: []
// }
// },
// // Score experiments:
// // a)Score down old records
// // "gauss": {
// // "dateStamp": {
// // "scale": "200d"
// // }
// // }
// // b)Promote grids!
// // "boost": "5",
// // "functions": [
// // {
// // "filter": { "match": { "codelist_spatialRepresentationType": "vector" } },
// // "random_score": {},
// // "weight": 23
// // },
// // {
// // "filter": { "match": { "codelist_spatialRepresentationType": "grid" } },
// // "weight": 42
// // }
// // ],
// // "max_boost": 42,
// // "score_mode": "max",
// // "boost_mode": "multiply",
// // "min_score" : 42
// }
// };
// var queryHook = query.function_score.query.bool.must;
var query = {
bool: {
must: []
}
};
var queryHook = query.bool.must;

var query_string;
var excludeFields = ['_content_type', 'fast', 'from', 'to', 'bucket',
Expand Down Expand Up @@ -79,7 +114,7 @@

// ranges criteria (for dates)
if (p.creationDateFrom || p.creationDateTo) {
query.bool.must.push({
queryHook.push({
range: {
createDate : {
gte: p.creationDateFrom || undefined,
Expand All @@ -90,7 +125,7 @@
});
}
if (p.dateFrom || p.dateTo) {
query.bool.must.push({
queryHook.push({
range: {
changeDate : {
gte: p.dateFrom || undefined,
Expand All @@ -116,13 +151,13 @@
for (var prop in termss) {
var terms = {};
terms[prop] = termss[prop];
query.bool.must.push({
queryHook.push({
terms: terms
});
}

if(query_string) {
query.bool.must.push({
queryHook.push({
query_string: query_string
});
}
Expand All @@ -134,7 +169,7 @@
[extent[2], extent[1]]
];

query.bool.must.push({
queryHook.push({
'geo_shape': {
'geom': {
'shape': {
Expand All @@ -145,9 +180,7 @@
}
}
});

}

params.query = query;

// Collapse could be an option to group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
aria-label="{{'clickToSelect' | translate}}"
data-ng-change="change()"/>

<span class="hidden">score:{{md._score}}</span>
<!--Source catalog Logo-->
<a data-ng-if="md.groupWebsite"
href="{{md.groupWebsite}}"
Expand Down

0 comments on commit ff184e9

Please sign in to comment.