如何使用通配符和空格从NodeJ执行elasticsearch查询

如何使用通配符和空格从NodeJ执行elasticsearch查询,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我在elasticsearch中索引了一组产品。我正在我的模式中搜索“标题”。 当我搜索“fre”或“fresh”时,我会看到一个结果。 但当我搜索“小新鲜”时,我没有看到任何结果。 是否可以将通配符与空格一起使用? 我加上了“未分析”,但没有运气 这是我的产品架构 const mongoose = require("mongoose"); const Schema = mongoose.Schema; var mongoosastic = require("mongoosastic"); co

我在elasticsearch中索引了一组产品。我正在我的模式中搜索“标题”。 当我搜索“fre”或“fresh”时,我会看到一个结果。 但当我搜索“小新鲜”时,我没有看到任何结果。 是否可以将通配符与空格一起使用? 我加上了“未分析”,但没有运气

这是我的产品架构

const mongoose = require("mongoose");
const Schema = mongoose.Schema;
var mongoosastic = require("mongoosastic");
const deepPopulate = require("mongoose-deep-populate")(mongoose);
var Owner = require("./user");
var Category = require("./category");
var Reviews = require("./review");

const ProductSchema = new Schema(
  {
    category: {
      type: Schema.Types.ObjectId,
      ref: "Category",
      es_indexed: true,
      es_type: "nested",
      es_include_in_parent: true
    },
    owner: {
      type: Schema.Types.ObjectId,
      ref: "User",
      es_indexed: true,
      es_type: "nested",
      es_include_in_parent: true
    },
    reviews: [
      {
        type: Schema.Types.ObjectId,
        ref: "Review",
        es_indexed: true,
        es_type: "nested",
        es_include_in_parent: true
      }
    ],
    image: { type: String, es_indexed: true },
    title: {
      type: String,
      es_indexed: "not_analyzed"
    },
    description: { type: String, es_indexed: true },
    price: { type: Number, es_indexed: true },
    crated: { type: Date, default: Date.now, es_indexed: true }
  },
  {
    toObject: { virtuals: true },
    toJSON: { virtuals: true }
  }
);

ProductSchema.virtual("averageRating").get(function() {
  var rating = 0;
  if (this.reviews.length == 0) {
    rating = 0;
  } else {
    this.reviews.map(review => {
      rating += review.rating;
    });
    rating = rating / this.reviews.length;
  }

  return rating;
});

ProductSchema.plugin(deepPopulate);
ProductSchema.plugin(mongoosastic, {
  populate: [{ path: "category" }, { path: "owner" }, { path: "reviews" }]
});


let Model = mongoose.model("Product", ProductSchema);
Model.createMapping(function(err, mapping) {
  if (err) {
    console.log("error creating mapping (you can safely ignore this)");
    console.log(err);
  } else {
    console.log("mapping created!");
    console.log(mapping);
  }
});
var stream = Model.synchronize();
var count = 0;

stream.on("data", (err, doc) => {
  console.log(doc);
  count++;
});
stream.on("close", () => console.log("indexed " + count + " documents!"));
stream.on("error", err => console.log(err));
Model.SyncToAlgolia();
Model.SetAlgoliaSettings({
  searchableAttributes: ["title"]
});
module.exports = Model;
这是我的搜索功能

async function search(frompage) {
  let fullString = "*" + "small fresh" + "*";
  let startsFrom = frompage * 10;
  console.log(fullString);
  const response = await esClient.search({
    index: "products",
    type: "product",
    from: startsFrom,
    body: {
      query: {
        wildcard: {
          title: fullString
        }
      }
    }
  });
  return response;
}