簡體   English   中英

在Elasticsearch中按腳本輸出過濾

[英]Filter by Script output in Elasticsearch

我在帶有腳本的Elasticsearch中有很好的輸出。

{
  "fields": [
    "_source"
  ],
  "script_fields": {
    "vermogen": {
      "script_file": "vermogen",
      "params": {
        "ruimtetemperatuur": 18,
        "aanvoertemperatuur": 85,
        "retourtemperatuur": 75
      }
    }
  },
  "query": {
    "bool": {
      "must": [],
      "must_not": [
        {
          "constant_score": {
            "filter": {
              "missing": {
                "field": "article.classification.Warmteafgifte EN 442 20gr C - 75/65"
              }
            }
          }
        }
      ]
    }
  }
}

並輸出以下內容:

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 5099,
    "max_score": 1,
    "hits": [
      {
        "_index": "items",
        "_type": "article",
        "_id": "AU7PHf_Ltb4sVpfKz-ip",
        "_score": 1,
        "_source": {
          "articleCode": "430003",
          "description": "Paneelradiator Henrad Standaard 300-10-800 270W ",
          "searchTerms": "Aangelaste strippen Ja | Aansluitcombi 18 onderzijde links/onderzijde rechts Ja | Aansluitcombi 32 zijkant linksboven/zijkant linksonder Ja | Aansluitcombi 37 zijkant linksboven/zijkant rechtsonder Ja | Aansluitcombi 62 zijkant rechtsboven/zijkant linksonder Ja | Aansluitcombi 67 zijkant rechtsboven/zijkant rechtsonder Ja | Aansluitcombi 81 onderzijde rechts/onderzijde links Ja | Aantal standaard aansluitingen 4 | Diepte 47mm | Diepte 47mm | Diepte 47mm | Draadaansluiting Binnendraad | Draadmaat (inch) 1/2\" | Glansgraad Glanzend | Hoogte 300mm | Hoogte 300mm | Hoogte 300mm | Kleur Wit | Lengte 800mm | Lengte 800mm | Lengte 800mm | Materiaal Staal | Max. werkdruk 10bar | Met aftapaansluiting Ja | Met ontluchtingsaansluiting Ja | N-exponent 1.283' | RAL-nummer 9016' | Standaard kleur Ja | Type 10 | Type 10 | Type 10 | Type 10 | Vlakke voorplaat Geen | Warmteafgifte bepaald door erkend EN 442 laboratorium Ja | Warmteafgifte EN 442 20gr C - 75/65 270W | Warmteafgifte EN 442 20gr C - 75/65 270W | Warmteafgifte EN 442 20gr C - 75/65 270W | Waterinhoud 1.51l | convector Paneelconvector Convectorradiator radiator radiator rad. | 0430003 | EC011022 | StandardB Radiator",
          "grossPrice": 37.24,
          "supplier": "HENRAD ",
          "productClass": "EC011022",
          "classification": {
            "Aangelaste strippen": "Ja",
            "Aansluitcombi 11 onderzijde links/onderzijde links": "Nee",
            "Aansluitcombi 18 onderzijde links/onderzijde rechts": "Ja",
            "Aansluitcombi 32 zijkant linksboven/zijkant linksonder": "Ja",
            "Aansluitcombi 37 zijkant linksboven/zijkant rechtsonder": "Ja",
            "Aansluitcombi 45 bovenzijde links/bovenzijde rechts": "Nee",
            "Aansluitcombi 54 bovenzijde rechts/bovenzijde links": "Nee",
            "Aansluitcombi 62 zijkant rechtsboven/zijkant linksonder": "Ja",
            "Aansluitcombi 67 zijkant rechtsboven/zijkant rechtsonder": "Ja",
            "Aansluitcombi 81 onderzijde rechts/onderzijde links": "Ja",
            "Aansluitcombi 88 onderzijde rechts/onderzijde rechts": "Nee",
            "Aansluitcombi MB middenboven/middenboven": "Nee",
            "Aansluitcombi MO middenonder/middenonder": "Nee",
            "Aantal standaard aansluitingen": "4",
            "Diepte": "47mm",
            "Draadaansluiting": "Binnendraad",
            "Draadmaat (inch)": "1/2\"",
            "Geschikt voor elektrisch element": "Nee",
            "Geschikt voor vochtige ruimte": "Nee",
            "Glansgraad": "Glanzend",
            "Hoogte": "300mm",
            "Kleur": "Wit",
            "Lengte": "800mm",
            "Materiaal": "Staal",
            "Max. werkdruk": "10bar",
            "Met aftapaansluiting": "Ja",
            "Met aftapper": "Nee",
            "Met bevestigingsmateriaal": "Nee",
            "Met blindstoppen": "Nee",
            "Met bovenbekleding": "Nee",
            "Met eenpuntsaansluiting": "Nee",
            "Met elektrisch element": "Nee",
            "Met ontluchter": "Nee",
            "Met ontluchtingsaansluiting": "Ja",
            "Met thermostatisch ventiel geïntegreerd": "Nee",
            "Met wandconsoles": "Nee",
            "Met zijbekleding": "Nee",
            "N-exponent": "1.283'",
            "RAL-nummer": "9016'",
            "Standaard kleur": "Ja",
            "Type": "10",
            "Vlakke voorplaat": "Geen",
            "Warmteafgifte bepaald door erkend EN 442 laboratorium": "Ja",
            "Warmteafgifte EN 442 20gr C - 75/65": "270W",
            "Waterinhoud": "1.51l"
          }
        },
        "fields": {
          "vermogen": [
            355.81461733776723
          ]
        }
      }
    ]
  }
}

到目前為止一切順利,但我想查詢此腳本的輸出。 這可能嗎?? 歡迎任何幫助!

為什么不使用腳本過濾器 ,調用執行腳本字段代碼的腳本並檢查條件。 有關如何嘗試的更多信息,請參見此處

順便說一句,這是我的grooooovy代碼:

if(!_source.classification.empty && (_source.classification["Warmteafgifte EN 442 20gr C - 75/65"] != null) && (!_source.classification["Warmteafgifte EN 442 20gr C - 75/65"].empty) && (_source.classification["N-exponent"] != null) && (!_source.classification["N-exponent"].empty))
{   
    def wattOrg = (_source.classification["Warmteafgifte EN 442 20gr C - 75/65"].replaceAll("[^\\d.]", "")) as float;   
    def exponent = _source.classification["N-exponent"].replaceAll("[^\\d.]", "") as float;
    def ruimtetemperatuurF = ruimtetemperatuur as float;
    def aanvoertemperatuurF = aanvoertemperatuur as float;
    def retourtemperatuurF = retourtemperatuur as float;

return (((((aanvoertemperatuurF + retourtemperatuurF) / 2F) - ruimtetemperatuurF) / 50F ) ** exponent) * wattOrg;
}
return -1;

//MSSQL: ROUND( POWER( (((Aanvoertemperatuur + Retourtemperatuur) / 2) - Ruimtetemperatuur) / 50, [N-exponent]) * WattOrg , 0)   AS Vermogen 

需要注意嗎? 不太擅長Java / Groovy代碼編寫...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM