1 package net.sourceforge.phpdt.core.tests.lucene;
3 import java.io.IOException;
5 import org.apache.lucene.analysis.standard.StandardAnalyzer;
6 import org.apache.lucene.document.Document;
7 import org.apache.lucene.index.Term;
8 import org.apache.lucene.queryParser.ParseException;
9 import org.apache.lucene.queryParser.QueryParser;
10 import org.apache.lucene.search.Hits;
11 import org.apache.lucene.search.IndexSearcher;
12 import org.apache.lucene.search.Query;
13 import org.apache.lucene.search.TermQuery;
15 public class PHPSearcher {
16 private IndexSearcher fSearcher;
17 private StandardAnalyzer analyzer;
19 public PHPSearcher(String indexPath) {
21 fSearcher = new IndexSearcher(indexPath);
22 analyzer = new StandardAnalyzer();
23 } catch (IOException e) {
28 public Hits getClassInfo(String ident) {
31 Query query = new TermQuery(new Term("c", ident));
32 hits = fSearcher.search(query);
33 int hitCount = hits.length();
35 for (int i = 0; (i < hitCount && i < 10); i++) {
37 for (int j = 0; j < doc.getValues("c").length; j++) {
38 System.out.println(doc.getValues("c")[j]);
41 } catch (IOException e) {
47 public Hits getFunctionInfo(String ident) {
50 // Query query = QueryParser.parse(ident, "f", new StandardAnalyzer());
51 Query query = new TermQuery(new Term("f", ident));
52 hits = fSearcher.search(query);
53 int hitCount = hits.length();
55 for (int i = 0; (i < hitCount && i < 10); i++) {
57 for (int j = 0; j < doc.getValues("f").length; j++) {
58 System.out.println(doc.getValues("f")[j]);
61 } catch (IOException e) {
67 public Hits getMethodInfo(String ident) {
70 // Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
71 Query query = new TermQuery(new Term("m", ident));
72 hits = fSearcher.search(query);
73 int hitCount = hits.length();
75 for (int i = 0; (i < hitCount && i < 10); i++) {
77 for (int j = 0; j < doc.getValues("m").length; j++) {
78 System.out.println(doc.getValues("m")[j]);
81 } catch (IOException e) {
86 public Hits getAttributeInfo(String ident) {
89 // Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
90 Query query = new TermQuery(new Term("a", ident));
91 hits = fSearcher.search(query);
92 int hitCount = hits.length();
94 for (int i = 0; (i < hitCount && i < 10); i++) {
96 for (int j = 0; j < doc.getValues("a").length; j++) {
97 System.out.println(doc.getValues("a")[j]);
100 } catch (IOException e) {