MongoDB Text Search AND multiple search words

后端 未结 4 1130
梦毁少年i
梦毁少年i 2020-11-29 01:13

I have an index on an array \"keys\" that I am using to provide full text functionality to my applicaiton.

With the release of 2.4.3, I\'d like to utilize the \"text

4条回答
  •  天涯浪人
    2020-11-29 01:52

    As @alecxe pointed out earlier, to do AND search on text index column you need to double quote each search word. Below is a quick one-liner for your requirement.

    db.supplies.runCommand("text", {search: "printer ink".split(" ").map(str => "\""+str+"\"").join(' ')})
    

提交回复
热议问题