Hello, here is my Searcher code:

Java Code:
import java.io.File;
import java.io.StringReader;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.CachingTokenFilter;
import org.apache.lucene.analysis.standard.StandardAnalyzer ;
import org.apache.lucene.document.Document;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query ;
import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.Highlighter;
import org.apache.lucene.search.highlight.SimpleHTMLFormatter;
import org.apache.lucene.search.highlight.SimpleFragmenter;
import org.apache.lucene.search.highlight.Fragmenter;
import org.apache.lucene.search.highlight.NullFragmenter;
import org.apache.lucene.search.Hits;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.Directory;
import org.apache.lucene.queryParser.QueryParser;


public class Searcher {
//------------------------------------------------------------------------------
    public static void main(String[] args) throws Exception{

    	Searcher searchDoc = new Searcher();
        File indexDir = new File("/home/paulius/Bandymai/Indexing/indexDir");
        String q="line2";
        if(!indexDir.exists() || !indexDir.isDirectory()){
            throw new Exception(indexDir + "does not exist of is not a directory.");
        }
        searchDoc.search(indexDir, q);
    }
//------------------------------------------------------------------------------
    public List search(File indexDir, String q) throws Exception {

    	List searchResult = new ArrayList();
        Directory fsDir = FSDirectory.getDirectory(indexDir);
        IndexSearcher is = new IndexSearcher(fsDir);

        Analyzer analyser = new StandardAnalyzer();
        Query parser = new QueryParser("text", analyser).parse(q);

        long start = new Date().getTime();
        Hits hits = is.search(parser);
        long end = new Date().getTime();

        QueryScorer scorer = new QueryScorer(parser);
        SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("< ", " >");
        
    	Highlighter highlighter = new Highlighter(formatter, scorer);
    	Highlighter high = new Highlighter(formatter, scorer);

        Fragmenter fragmenter = new NullFragmenter();
    	Fragmenter fragment = new SimpleFragmenter();

    	highlighter.setTextFragmenter(fragmenter);
    	high.setTextFragmenter(fragment);

        for(int i=0; i<hits.length(); i++){
    
            Document doc = hits.doc(i);
            String lns = doc.get("text");
            TokenStream lines = analyser.tokenStream("text", new StringReader(lns));
            CachingTokenFilter filter = new CachingTokenFilter(lines);
            
            String highlightedLines = highlighter.getBestFragment(analyser, lns , q);
            
            filter.reset();
            String highlight = high.getBestFragments(filter, lns, 500, "");
            SearchResultBean resultBean = new SearchResultBean();
            resultBean.setHitResult(highlight);
            resultBean.setQuote(highlightedLines);
            searchResult.add(resultBean);
            System.out.println(resultBean.getHitResult());
            System.out.println("");
            System.out.println(resultBean.getQuote());
            System.out.println("");
        }

        System.err.println("Found " + hits.length() + " document(s)(in " + (end-start) + " milliseconds) that matched query '" + q + "':");
        return searchResult;
    }
//------------------------------------------------------------------------------
}

could anybody tell me how to get only those lines where searching q is?
I search q that is a word or phrase and I want to get only those lines where the q is.

Here is my xml document:

<text>
1. line1
2. line1 line1 line2
3. line1 line2
4. line1 line1 line1
5. line2 line1 line2
</text>

For example I need to get only where the word is line2. It would be 2, 3, 5 lines. How can I do it?

Please, help...