2

I am searching a lot for this but I couldn't find any solution till now. I have a large query with the combination of proximity search. I need to find out where is the exact location of results in the query. For example a part of query is "hospital"~2 "readmissio"~2 . Now Lucene retrieve the correct documents and one of them contain the correct value "hospital re-admission" but how I can highlight the "readmissio" in the query for the "re-admission" from the document. There are some workaround like levenshtein but due to huge amount of retrieval it is not practical, I hope there is some solution within lucene to find out the position of retrieved data from the query? Please advice.

    string newQueryString = "";
    string querystring = "To determine whether high performing hospitals with low 30 day risk standardized hospital readmissio rates have a lower proportion of readmission";
    string[] tokens = NLP.Tokenize(querystring);
    for (int i = 0; i < tokens.Length; i++)
    {
        string token = tokens[i];
        token = "\"" + token + "\"" + "~" + 2;

        // add token to new string expression
        newQueryString = newQueryString + " " + token;
    }

    query = MultiFieldQueryParser.Parse(Lucene.Net.Util.Version.LUCENE_CURRENT,
    new string[] { newQueryString }
    , new string[] { "TERM" },
    selectedAnalyzer);



    TopDocs tp = indexSearcher.Search(query, 1);
    int max = tp.TotalHits;

    List<Lucene.Net.Documents.Document> ids = new List<Lucene.Net.Documents.Document>();
    TopScoreDocCollector collector = TopScoreDocCollector.Create(max+1, true);
    indexSearcher.Search(query, collector);
    ScoreDoc[] hits = collector.TopDocs().ScoreDocs;
    for (int i = 0; i < hits.Length; i++)
    {

        int docId = hits[i].Doc;
        Lucene.Net.Documents.Document doc = indexSearcher.Doc(docId);
        string concept = doc.GetFieldable("TERM").StringValue;


        string[] contentTerms = NLP.Tokenize(querystring);
        ITermFreqVector tfvector = reader.GetTermFreqVector(docId, "TERM");
        TermPositionVector tpvector = (TermPositionVector)tfvector;

        for (int k = 0; k < contentTerms.Length; k++)
        {
            string[] terms = tfvector.GetTerms();
            int termidx = tfvector.IndexOf(contentTerms[k].Trim()); /// How to have readmission/readmissions here????? 
            int[] termposx = tpvector.GetTermPositions(termidx);
            TermVectorOffsetInfo[] tvoffsetinfo = tpvector.GetOffsets(termidx);

            int offsetStart = 0;
            int offsetEnd = 0;
            List<Tokens> conceptList = new List<Tokens>();
            for (int j = 0; j < tvoffsetinfo.Length; j++)
            {
                offsetStart = tvoffsetinfo[j].StartOffset;
                offsetEnd = tvoffsetinfo[j].EndOffset;
                string key = concept.Substring(offsetStart, offsetEnd - offsetStart);
                //////////////// Code continue////////////////
            }

        }
    }

as it shows how can I highlight the "redamissi" part in my querystring for the concept "hospital readmission". ??? or in another example if I have readmissions in my query how can i highlight it for the retrieved value of "re-admission" or "admission" ???

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
Afrooz
  • 21
  • 3
  • Could you please post existing code, queries, and try to restructure your question? I'm having a hard time following what you're asking for. Thanks! – Lizz Feb 21 '14 at 20:24
  • 1
    Thanks Lizz, I know a little bit confusing. – Afrooz Feb 21 '14 at 20:39

0 Answers0