范围或缺失 - ElasticSearch - 查询DSL

时间:2018-05-23 11:08:09

标签: elasticsearch elasticsearch-5 kibana-6

我目前正在尝试将以下逻辑纳入ES查询 - # START: Display name and purpose of invoked script $path = $MyInvocation.MyCommand.Definition Clear-Host Write-Host $path Write-Host " " Write-Host "This script will allow you to do the following in a single-step process:" Write-Host "(1) RENAME this computer" Write-Host "(2) JOIN it to MYDOMAIN" Write-Host "(3) MOVE it to a target OU" Write-Host "(4) REBOOT" Write-Host " " Pause # Function: PAUSE Function Pause ($Message = "Press any key to continue . . . ") { if ((Test-Path variable:psISE) -and $psISE) { $Shell = New-Object -ComObject "WScript.Shell" $Button = $Shell.Popup("Click OK to continue.", 0, "Script Paused", 0) } else { Write-Host -NoNewline $Message [void][System.Console]::ReadKey($true) Write-Host } Write-Host " " } # Function: Define the parameters Function Define-Parameters { # Specify new computer name, with validation and TRAP $WS_NewName = $null while ($null -eq $WS_NewName) { [ValidateLength(8,15)]$WS_NewName = [string](Read-Host -Prompt "NEW NAME of computer (8-15 chars.)" ) TRAP {"" ;continue} } Write-Host " " # Domain to join. $DomainToJoin = 'mydomain.net' # Specify the target OU, with validation and trap $baseOU='OU=Offices OU,DC=mydomain,DC=net' $OU2 = $null while ($null -eq $OU2) { [ValidateLength(2,2)]$OU2 = [string](Read-Host -Prompt 'Target OU (TWO-LETTER code for your office)' ) TRAP {"" ;continue} } Write-Host " " $LocDN = "OU=$OU2,$baseOU" } # Function: Summary and confirmation screen for defined parameters. Function Confirm-Parameters { Write-Host "===========================================================================" Write-Host "Please confirm that you are joining this computer to $DomainToJoin (MYDOMAIN)" Write-Host "with the following parameters:" Write-Host "" Write-Host "" Write-Host "Computer's NEW NAME: $WS_NewName" # Write-Host "Domain to Join: $DomainToJoin" Write-Host "TARGET mission OU: $OU2" } # Call Define-Parameters Function Define-Parameters # Call Confirm-Parameters Function Confirm-Parameters <# Some more code here #> # FINAL COMMAND if all else works: Join the computer to the domain, rename it, and restart it. # Add-Computer -DomainName $DomainToJoin -OUPath $LocDN -NewName $WS_NewName -Restart 是否存在?如果是的话,它应该在400-600之间;但它也可能缺失。

以下查询不起作用,我认为需要更改和更正。

@ResponseBody
@GetMapping(value = "/get")
public void getFile(HttpServletResponse response, @RequestParam(value = "id") String id) throws Exception {
    byte[] file = findFileById(id);

    response.reset();
    response.setBufferSize(BUFFER_SIZE);
    try {
        response.getOutputStream().write(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

最初的要求是将过滤器保存在范围为400-600的 Kibana 信息中心中,或者缺少过滤器。

1 个答案:

答案 0 :(得分:0)

要进行您建议的查询,您需要执行以下操作:

The original requirement is to save a filter in a Kibana dashboard with range 400-600 OR it's missing. as:

{
  "query": {
    "bool": {
      "minimum_should_match": 1,
      "should": [
        {
          "range": {
            "http_code": {
              "gte": 400,
              "lt": 600
            }
          }
        },
        {
          "bool": {
            "must_not": {
              "exists": {
                "field": "http_code"
              }
            }
          }
        }
      ]
    }
  }
}