使用字词查找的多匹配查询搜索多个索引elasticsearch 6.x

时间:2018-12-20 22:08:36

标签: elasticsearch nest

全部,     我正在构建一个带有Serach术语并在不同索引的不同字段中查找的NEST 6.x查询。     这是我到目前为止获得的结果,但未返回我期望的任何结果。

请参阅下面的详细信息

使用的指标

  1. dev-sample-search
  2. user-agents-search

搜索的工作方式如下。

  1. 针对查询字段( 27921093 )搜索值 字段 agentNumber,customerName,fileNumber,documentid (这些都是            分析文件)。

  2. 搜索应将文档限制为用户的 agentNumbers sampleuser@gmail.com 有权访问(            user-agents-search)添加到下面。

  3. 代理编号,客户名称,文件编号,文档ID 和状态为 索引dev-sample-search的一部分。

  4. 状态字段定义为关键字

  5. user-agents-search 索引中的字段均为关键字

    示例用户代理搜索索引数据:

     {
                  "id": "sampleuser@gmail.com"",
                  "user": "sampleuser@gmail.com"",
                  "agentNumber": [
                    "123.456.789",
                    "1011.12.13.14"
                  ]
        }
    

示例dev-sample-search索引数据:

{

          "agentNumber": "123.456.789",          
          "customerName": "Bank of america",
          "fileNumber":"test_file_1123",
          "documentid":"1234456789"
 }

GET dev-sample-search/_search
{
  "from": 0,
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "type": "best_fields",
            "query": "27921093",
            "operator": "and",
            "fields": [
              "agentNumber",
              "customerName",
              "fileNumber",              
              "documentid^10"
            ]
          }
        }
      ],
      "filter": [
        {
          "bool": {
            "must": [
              {
                "terms": {
                  "agentNumber": {
                    "index": "user-agents-search",
                    "type": "_doc",
                    "user": "sampleuser@gmail.com",
                    "path": "agentNumber"
                  }
                }
              },
              {
                "bool": {
                  "must_not": [
                    {
                      "terms": {
                        "status": {
                          "value": "pending"
                        }
                      }
                    },
                    {
                      "term": {
                        "status": {
                          "value": "cancelled"
                        }
                      }
                    },
                    {
                      "term": {
                        "status": {
                          "value": "app cancelled"
                        }
                      }
                    }
                  ],
                  "should": [
                    {
                      "term": {
                        "status": {
                          "value": "active"
                        }
                      }
                    },
                    {
                      "term": {
                        "status": {
                          "value": "terminated"
                        }
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}

1 个答案:

答案 0 :(得分:1)

我看到了一些您可能要看的东西:

  1. public UserMenuInterface() { InitializeComponent(); this.MenuImageContextMenu.Loaded += FindControl; } private void FindControl(object sender, RoutedEventArgs e) { var BeverageMenuItem = this.MenuImageContextMenu.Template.FindName("BeverageMenuItem", MenuImage) as CustomMenuItem; } 查找查询中,public class Frame extends JFrame { public Frame() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); JFrame loader = new JFrame(); loader.setSize(screenSize.width / 3, screenSize.height / 3); loader.add(new LaunchPanel(screenSize.width, screenSize.height)); loader.setLocationRelativeTo(null); loader.setResizable(false); loader.setUndecorated(true); loader.repaint(); loader.setVisible(true); } } 应该为public class LaunchPanel extends JPanel{ public LaunchPanel(int w, int h) { BufferedImage image = null; try { image = ImageIO.read(new File("myImagePath.jpg")); } catch (IOException e) { e.printStackTrace(); } this.setSize(w, h); Image scaledImage = image.getScaledInstance(this.getWidth() / 3, this.getHeight() / 3,Image.SCALE_SMOOTH); JLabel label = new JLabel(new ImageIcon(scaledImage)); this.add(label); label.setLocation(0, 0); } }
  2. 如果terms子句中至少有一个"user": "sampleuser@gmail.com",子句匹配,请在包含"id": "sampleuser@gmail.com",子句的should查询中设置filter