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 getIncludeInfo(String ident) {
50 // Query query = QueryParser.parse(ident, "f", new StandardAnalyzer());
51 Query query = new TermQuery(new Term("i", 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("i").length; j++) {
58 System.out.println(doc.getValues("i")[j]);
61 } catch (IOException e) {
67 public Hits getFunctionInfo(String ident) {
70 // Query query = QueryParser.parse(ident, "f", new StandardAnalyzer());
71 Query query = new TermQuery(new Term("f", 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("f").length; j++) {
78 System.out.println(doc.getValues("f")[j]);
81 } catch (IOException e) {
87 public Hits getMethodInfo(String ident) {
90 // Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
91 Query query = new TermQuery(new Term("m", ident));
92 hits = fSearcher.search(query);
93 int hitCount = hits.length();
95 for (int i = 0; (i < hitCount && i < 10); i++) {
97 for (int j = 0; j < doc.getValues("m").length; j++) {
98 System.out.println(doc.getValues("m")[j]);
101 } catch (IOException e) {
106 public Hits getAttributeInfo(String ident) {
109 // Query query = QueryParser.parse(ident, "m", new StandardAnalyzer());
110 Query query = new TermQuery(new Term("a", ident));
111 hits = fSearcher.search(query);
112 int hitCount = hits.length();
114 for (int i = 0; (i < hitCount && i < 10); i++) {
116 for (int j = 0; j < doc.getValues("a").length; j++) {
117 System.out.println(doc.getValues("a")[j]);
120 } catch (IOException e) {