术语的弹性搜索

时间:2019-08-29 12:46:53

标签: elasticsearch

我对Elasticsearch和查询DSL非常陌生。我正在尝试使用node.js和from matplotlib.backends.backend_pdf import PdfPages import matplotlib.pyplot as plt import numpy as np pp = PdfPages('multipage.pdf') x=np.arange(1,10) y=np.arange(1,10) fig=plt.figure() ax1=fig.add_subplot(211) # ax1.set_title("cell" + keyInTags) # ax1.plot(x, y, color='k') # ax.plot(x, y_red, color='k') ax2=fig.add_subplot(212) pp.savefig(fig) fig2=plt.figure() ax1=fig2.add_subplot(321) ax1.plot(x, y, color='k') ax2=fig2.add_subplot(322) ax2.plot(x, y, color='k') ax3=fig2.add_subplot(313) pp.savefig(fig2) pp.close() 构建模糊搜索支持的过滤器端点。

我的数据结构如下;

async doesUserExists(createUserDTO: CreateUserDTO): any {
    const user = await this.userModel.findOne({ userName: createUserDTO.userName });
    if(user.length != 0){
        return true;
    }
    return false;
}

我正在尝试获得类别4或5(产品1、2和4)的点击量

在单独或相同的查询中,我还尝试从这些匹配中创建一组// add a user @Post('/create') async addUser(@Res() res, @Body() createUserDTO: CreateUserDTO) { if(await this.userService.doesUserExists()){ return res.status(HttpStatus.OK).json({ message: "User already exists" }) } const user = await this.usersService.addUser(createUserDTO); return res.status(HttpStatus.OK).json({ message: "User has been created successfully", user }) } 。应该是;

@elastic/elasticsearch

直到现在我创建此查询;

{
  name: "product 1",
  price: 43,
  categories: [5, 6],
  description: "lorem...",
  product_attribute_values: [{
    attribute_id: 1,
    attribute_value_id: 1
  }]
},
{
  name: "product 2",
  price: 45,
  categories: [4, 6],
  description: "lorem...",
  product_attribute_values: [{
    attribute_id: 1,
    attribute_value_id: 2
  }]
},
{
  name: "product 3",
  price: 57,
  categories: [1, 6, 7],
  description: "lorem...",
  product_attribute_values: [{
    attribute_id: 2,
    attribute_value_id: 3
  }]
},
{
  name: "product 4",
  price: 79,
  categories: [5],
  description: "lorem...",
  product_attribute_values: [{
    attribute_id: 2,
    attribute_value_id: 4
  }]
},

但是我不确定这是否是正确的方法。 PS:另一个令我困惑的小事情是如何以编程方式更改product_attribute_values值。我将对这些结果使用分页,并且我需要所有可能的属性,包括那些受 product_attribute_values: [{ attribute_id: 1, attribute_value_id: 1 }, { attribute_id: 1, attribute_value_id: 2 }, { attribute_id: 2, attribute_value_id: 4 }] 限制过滤的属性。

1 个答案:

答案 0 :(得分:1)

如果您尝试更新的值是静态的还是不是基于查询本身返回的文档,则可以使用update_by_query(而不是_search)直接更新您的第一个查询返回的文档(在这种情况下)在您的nodeJS代码中执行起来可能会更容易。)

对于index.max_result_window,您可以使用index setting api设置其值:

PUT /products/_settings
{
    "index" : {
        "max_result_window" : 50000
    }
}

max_result_windows的链接文档包含指向其他处理结果分页的方法的链接;您可能也想探索一下。处理分页(和大小限制)的基本方法是在查询中使用“ from”参数。 from是结果中文档的位置,从该位置开始接收值直到大小。

例如: from:0 size:1000将返回查询结果的前1k个文档(第1页) from:1000 size:1000 is page 2(接下来的1k,从1k到2k开始) 从:2000大小:1000是第3页 等等,等等... sniff

相关问题