我有以下数据的Cassandra表:
cqlsh:test> SELECT * FROM test1 WHERE solr_query='{"q":"address:*"}';
name | address | age | solr_query
-------+------------------------------+-----+------------
test3 | road3 united states | 23 | null
test4 | road 123 canada | 23 | null
test2 | street2 united states | 22 | null
test1 | 123 california united states | 21 | null
test5 | 123 Texas united states | 23 | null
with schema:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<schema name="TestSolrSchema" version="1.5">
<types>
<fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
<fieldType class="org.apache.solr.schema.TrieIntField" name="TrieIntField"/>
</types>
<fields>
<field docValues="true" indexed="true" multiValued="false" name="name" stored="true" type="StrField"/>
<field docValues="true" indexed="true" multiValued="false" name="address" stored="true" type="StrField"/>
<field docValues="true" indexed="true" multiValued="false" name="age" stored="true" type="TrieIntField"/>
</fields>
<uniqueKey>name</uniqueKey>
</schema>
带空格的字符串的完美匹配 cqlsh:试验&gt; SELECT * FROM test1 WHERE solr_query ='{“q”:“address:\”123 california united states \“”}';
name | address | age | solr_query
-------+------------------------------+-----+------------
test1 | 123 california united states | 21 | null
但如果我想搜索以“123”开头的字符串(带空格的字符串的正则表达式),则会失败。 (尝试了其他solr query: {"q":"address:\"123\"*"})
cqlsh:test> SELECT * FROM test1 WHERE solr_query='{"q":"address:\"123\""}';
name | address | age | solr_query
------+---------+-----+------------
(0 rows)
有没有办法在带有空格的solr字符串字段类型上完成正则表达式?
答案 0 :(得分:1)
尝试SELECT * FROM test1 WHERE solr_query='{"q":"address:123*"}';
您删除了引号,因为您不再需要完全匹配。