dqd3690 2018-10-02 14:31
浏览 39

Couchbase精确值匹配

I am using Couchbase 5 and Go Lang 1.11, trying to query results based on an exact value.

The code below is finding rows with a status of "Available" and "Not Available". How can I make it only return "Available" rows?

qp.And(cbft.NewConjunctionQuery( cbft.NewMatchQuery("Available").Field("status") ))
  • 写回答

1条回答

  • dtxa49711 2018-10-03 08:08
    关注

    It will depend on how you analyze the input field, it would help to know what analyzer you are using, but I'll assume the default, "standard", analyzer for now.

    Don't use the default analyzer for this case. As Matt asked in his comment, you are trying to do a direct match of exact text in a phrase, which is a little different than most text search users. So you don't really want the text to be tokenized into smaller pieces.

    Create a custom analyzer with the Couchbase search GUI that uses the "single" tokenizer so that all the text in the field will be kept together. Or you could just use the "keyword" analyzer which is probably close enough for you. Set that as your default analyzer and your query should work as expected.

    If you are looking for another approach, then a term or term phrase query may be more what you are after, but you'll still have to be conscious of how analyzers are working.

    Set default analyzer for Couchbase full-text search analyzer to use "keyword"

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘