srikanthreddy mora
2008-07-12 04:46:58 UTC
hello to all respected persons
I am working on zend lucene
*i have written a searching functionality in that i need
the terms/fields that are matched in the file.*
i.e if there is a text like " abc def xyz ddddd vvvvv cccccc zzzzz nub gggg
kkkkk"
i am searching on ==== (cccccc or xyz or nub)
and i am searching some no of html files . so i need the terms matched on
each and every html file
so how can i get it.
let us see the some code ....
*require_once 'Zend/Search/Lucene.php';
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$index = Zend_Search_Lucene::open('/home/......../search/indexs');
//here $field and $location or some variables with will get value from
input.
$query_string = " ";
if ( $field != "") {
$query_string .= "(" . $field . ")";
}
if ( $field != "") {
if ( $location != "") {
$query_string .= " "."AND location:(" .$location . ")";
}
} else {
$query_string .= "location:(" .$location . ")";
}
$user_query = Zend_Search_Lucene_Search_QueryParser::parse($query_string,
'iso-8859-5');
$query_field = Zend_Search_Lucene_Search_QueryParser::parse($field,'iso-885
9-5'); </b>
$hits = $index->find($user_query);
$hits_length = count($hits);
for($i=0; $i<$hits_length;$i++) {
$search_value_arr[$i]->title = $hits[$i]->title;
if ( $hits[$i]->location != "") {
$search_value_arr[$i]->location = $hits[$i]->location;
}
if ( $hits[$i]->keywords != "") {
$search_value_arr[$i]->keywords = $hits[$i]->keywords;
}
$body = $hits[$i]->body;
$text = $body;
if ( $field != "") {
$color = 0;
$hightext = $query_field->highlightMatches($text);
$search_value_arr[$i]->body = $hightext;
}
$search_value_arr[$i]->score = $hits[$i]->score;
$search_value_arr[$i]->url = $hits[$i]->url;
$search_value_arr[$i]->date = $hits[$i]->date;
}
this is my code in short formet
1.......
so in this i need the all matching terms means in a document if i have given
10 words to match it found four found in that and i need that four keywords
or tokens.
2 ......
and i want to highlight my body in highlightmatcges() founction just like as
google.
i.e in whichline it found match then related lines only need to return
can any one give a reply to this.
Thanku.*
I am working on zend lucene
*i have written a searching functionality in that i need
the terms/fields that are matched in the file.*
i.e if there is a text like " abc def xyz ddddd vvvvv cccccc zzzzz nub gggg
kkkkk"
i am searching on ==== (cccccc or xyz or nub)
and i am searching some no of html files . so i need the terms matched on
each and every html file
so how can i get it.
let us see the some code ....
*require_once 'Zend/Search/Lucene.php';
require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$index = Zend_Search_Lucene::open('/home/......../search/indexs');
//here $field and $location or some variables with will get value from
input.
$query_string = " ";
if ( $field != "") {
$query_string .= "(" . $field . ")";
}
if ( $field != "") {
if ( $location != "") {
$query_string .= " "."AND location:(" .$location . ")";
}
} else {
$query_string .= "location:(" .$location . ")";
}
$user_query = Zend_Search_Lucene_Search_QueryParser::parse($query_string,
'iso-8859-5');
$query_field = Zend_Search_Lucene_Search_QueryParser::parse($field,'iso-885
9-5'); </b>
$hits = $index->find($user_query);
$hits_length = count($hits);
for($i=0; $i<$hits_length;$i++) {
$search_value_arr[$i]->title = $hits[$i]->title;
if ( $hits[$i]->location != "") {
$search_value_arr[$i]->location = $hits[$i]->location;
}
if ( $hits[$i]->keywords != "") {
$search_value_arr[$i]->keywords = $hits[$i]->keywords;
}
$body = $hits[$i]->body;
$text = $body;
if ( $field != "") {
$color = 0;
$hightext = $query_field->highlightMatches($text);
$search_value_arr[$i]->body = $hightext;
}
$search_value_arr[$i]->score = $hits[$i]->score;
$search_value_arr[$i]->url = $hits[$i]->url;
$search_value_arr[$i]->date = $hits[$i]->date;
}
this is my code in short formet
1.......
so in this i need the all matching terms means in a document if i have given
10 words to match it found four found in that and i need that four keywords
or tokens.
2 ......
and i want to highlight my body in highlightmatcges() founction just like as
google.
i.e in whichline it found match then related lines only need to return
can any one give a reply to this.
Thanku.*