Skip to content

Facets - aggLang variable it's not always replaced properly producing different results in the search filters #7252

Description

@josegar74

Describe the bug

When configuring a facet with aggLang variable

  "OrgForResource": {
    "terms": {
      "field": "OrgForResourceObject.${aggLang}",
      "include": ".*",
      "size": 20
    },
    "meta": {
      "caseInsensitiveInclude": true
    }
  },

This code calculates the value to replace in aggLanguage

this.getLanguageConfig = function (any, state) {
var languageFound = false,
searchLanguage = "lang" + state.forcedLanguage,
uiLanguage = "lang" + gnGlobalSettings.iso3lang,
aggLanguage = "lang" + gnGlobalSettings.iso3lang;
state.detectedLanguage = undefined;
if (state.forcedLanguage !== undefined) {
searchLanguage = aggLanguage = "lang" + state.forcedLanguage;
languageFound = true;
} else if (state.languageStrategy === "searchInDetectedLanguage") {
searchLanguage = this.autoDetectLanguage(any || "", state.languageWhiteList);
state.detectedLanguage = searchLanguage;
languageFound = searchLanguage !== "und";
if (languageFound) {
searchLanguage = aggLanguage = "lang" + searchLanguage;
} else {
searchLanguage = "\\*";
}
} else if (state.languageStrategy === "searchInUILanguage") {
searchLanguage = aggLanguage = uiLanguage;
languageFound = true;
} else if (
state.languageStrategy &&
state.languageStrategy.indexOf("searchInThatLanguage") === 0
) {
var config = state.languageStrategy.split(":");
if (config.length !== 2) {
console.warn(
"When using language strategy searchInThatLanguage, configuration MUST be like searchInThatLanguage:fre"
);
} else {
searchLanguage = aggLanguage = "lang" + config[1];
languageFound = true;
}
} else if (state.languageStrategy === "searchInAllLanguages") {
languageFound = false;
searchLanguage = "\\*";
uiLanguage = "\\*";
aggLanguage = "default";
}
return {
languageFound: languageFound,
searchLanguage: searchLanguage,
uiLanguage: uiLanguage,
aggLanguage: aggLanguage
};
};

Sometimes the parameter state only contains a property filter and others contains additional properties like languageStrategy that causes different output.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://apps.titellus.net/geonetwork/srv/dut/catalog.search#/home (Dutch UI) and select from the menu the search option Zoeken --> The Organisation facet is displayed

The search request request the aggregation field OrgForResourceObject.default

  1. In other tab open the search page in Dutch --> https://apps.titellus.net/geonetwork/srv/dut/catalog.search#/search --> The organisation facet is not displayed

The search request request the aggregation field OrgForResourceObject.langdut

Expected behavior
Results are the same.


This code probably should be initialised with the settings values for languageStrategy and other fields:

It's unclear in case 1. how is filled, as the code that seems to fill that object it's not executed:

$scope.searchObj.state = {
filters: {},
exactMatch: false,
titleOnly: false,
languageStrategy: "searchInAllLanguages",
forcedLanguage: undefined,
languageWhiteList: undefined,
detectedLanguage: undefined
};

@fxprunayre any idea about this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions