Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jun 21, 2012 @ 19:47
    Hendy Racher
    0

    Get raw Lucene query after using the Examine Fluent API

    Hi,

    Is it possible to progmatically get the raw Lucene query generated by the Examine fluent API ?

    The closest method I've found so far is query.Compile().ToString() which returns the raw query (along with another property). Is chopping this string the only way to get to the actual query ? or is there a better approach ?

    TIA,

    Hendy

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jun 22, 2012 @ 10:53
    Ismail Mayat
    2

    Hendy,

    the criteria object .ToString() not the query object.

    regards

     

    Ismail

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jun 22, 2012 @ 13:00
    Hendy Racher
    3

    criteria.ToString() and query.ToString() both return the raw query in a string, but unfortunatley along with another property.

    here's a dirty hack to get the raw query:

    string stringToParse = criteria.ToString();
    int indexOfPropertyValue = stringToParse.IndexOf("LuceneQuery:") + 12;
    string rawQuery = stringToParse.Substring(indexOfPropertyValue).TrimEnd('}');
Please Sign in or register to post replies

Write your reply to:

Draft