Skip to content

Commit 69e75a0

Browse files
author
Theo van Kraay
committed
re-factor
1 parent 1a37d94 commit 69e75a0

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

articles/managed-instance-apache-cassandra/search-lucene-index.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Cassandra Lucene Index, derived from Stratio Cassandra, is a plugin for Apache C
2727
- Deploy an Azure Managed Instance for Apache Cassandra cluster. You can do this via the [portal](create-cluster-portal.md) - Lucene indexes will be enabled by default.
2828
- Connect to your cluster from [CQLSH](create-cluster-portal.md#connecting-from-cqlsh).
2929

30-
## Create keyspace and table with Lucene Index
30+
## Create data with Lucene Index
3131

3232
1. In your `CQLSH` command window, create a keyspace and table as below:
3333

@@ -64,9 +64,7 @@ Cassandra Lucene Index, derived from Stratio Cassandra, is a plugin for Apache C
6464
};
6565
```
6666

67-
## Create data and search
68-
69-
Insert the following sample tweets:
67+
1. Insert the following sample tweets:
7068

7169
```SQL
7270
INSERT INTO tweets (id,user,body,time,latitude,longitude) VALUES (1,'theo','Make money fast, 5 easy tips', '2023-04-01T11:21:59.001+0000', 0.0, 0.0);
@@ -76,13 +74,34 @@ Insert the following sample tweets:
7674
INSERT INTO tweets (id,user,body,time,latitude,longitude) VALUES (5,'quetzal','Click my link, like my stuff!', '2023-04-01T11:21:59.001+0000', 40.3930, -3.7329);
7775
```
7876

77+
## Controlling read consistency
78+
79+
1. The index you created earlier will index all the columns in the table with the specified types, and it will be refreshed once per second. Alternatively, you can explicitly refresh all the index shards with an empty search with consistency ALL:
80+
81+
```SQL
82+
CONSISTENCY ALL
83+
SELECT * FROM tweets WHERE expr(tweets_index, '{refresh:true}');
84+
CONSISTENCY QUORUM
85+
```
86+
7987
1. Now, you can search for tweets within a certain date range:
8088

8189
```SQL
8290
SELECT * FROM tweets WHERE expr(tweets_index, '{filter: {type: "range", field: "time", lower: "2023/03/01", upper: "2023/05/01"}}');
8391
```
8492

85-
1. Now, to search the top 100 more relevant tweets where body field contains the phrase “Click my link” within the aforementioned date range:
93+
1. This search can also be performed by forcing an explicit refresh of the involved index shards:
94+
95+
```SQL
96+
SELECT * FROM tweets WHERE expr(tweets_index, '{
97+
filter: {type: "range", field: "time", lower: "2023/03/01", upper: "2023/05/01"},
98+
refresh: true
99+
}') limit 100;
100+
```
101+
102+
## Search data
103+
104+
1. To search the top 100 more relevant tweets where body field contains the phrase “Click my link” within the aforementioned date range:
86105

87106
```SQL
88107
SELECT * FROM tweets WHERE expr(tweets_index, '{
@@ -147,24 +166,6 @@ Insert the following sample tweets:
147166
}') limit 100;
148167
```
149168

150-
1. The index you created earlier will index all the columns in the table with the specified types, and it will be refreshed once per second. Alternatively, you can explicitly refresh all the index shards with an empty search with consistency ALL:
151-
152-
```SQL
153-
CONSISTENCY ALL
154-
SELECT * FROM tweets WHERE expr(tweets_index, '{refresh:true}');
155-
CONSISTENCY QUORUM
156-
```
157-
158-
1. The same search can be performed forcing an explicit refresh of the involved index shards:
159-
160-
```SQL
161-
SELECT * FROM tweets WHERE expr(tweets_index, '{
162-
filter: {type: "range", field: "time", lower: "2023/03/01", upper: "2023/05/01"},
163-
refresh: true
164-
}') limit 100;
165-
```
166-
167-
168169

169170
## Next steps
170171

0 commit comments

Comments
 (0)