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 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?