如何在SQLite全文搜索(fts5)中排除字段

时间:2019-09-19 02:48:19

标签: sql sqlite

要在所有字段中进行搜索以在sqlite中进行全文搜索,我可以这样做:

class Node {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
  }
}

class BinarySearchTree {
  constructor() {
  this.root = null;
  }

  insert(value){
  let newNode = new Node(value);

   if(this.rootNode == null){
    this.rootNode = newNode;
    return this;
   }else{
    let currentNode = this.rootNode;
     while(true){
      if(value > currentNode.value){
       if(currentNode.right == null){
        currentNode.right = newNode;
        return this;
       }
      currentNode = currentNode.right;
     }else if(value < currentNode.value){
      if(currentNode.left == null){
       currentNode.left = newNode;
       return this;
     }
    currentNode = currentNode.left;
  }
 }
 }
}

是否有一种方法可以从其中排除一个或多个字段,例如,使用伪代码:

SELECT * FROM investments_v ('facebook');

那怎么办?

2 个答案:

答案 0 :(得分:1)

来自the documentation

  

如果列过滤器规范前面带有“-”字符,则将其解释为不匹配的列列表。

类似

SELECT *
FROM investmests_v
WHERE investments_v MATCH '-url:facebook';

答案 1 :(得分:0)

我还没有找到一种方法来做到这一点,但是相反的方法是将所有字段都包括在内,例如,

SELECT * FROM investments_v ('{company_country_code company_name}: "facebook"');