Am a newbie to Lucene an working on a city search API using Lucene. If user types in san francisco as search input, then it should give cities with exact match only and not San Jose /San Diego,etc.
How should i index city names in Lucene?and which Lucene analyzer and query class do i need to use?
Upvotes: 0
Views: 391
Reputation: 302
<?php
if(isset($_POST['submit']) && $_POST['submit']=='submit' ){
$city = $_POST['city'];
$query = "SELECT * FROM libreary WHERE city LIKE'".$city."'";
$row = mysqli_query($con,$query);
$result = mysqli_num_rows($row);
if($result>0){
while($row1 = mysqli_fetch_array($row)){
print_r($row1);
}
}
$respon['Response'] = $response;
print_r(json_encode($respon));
}
?>
Upvotes: 0
Reputation: 5042
Index your content with StandardAnalyzer. And then use PhraseQuery to search. For this, simply use the query string as "san francisco" with double quotes.
Upvotes: 3