Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 18, 2010 @ 12:00
    Ismail Mayat
    0

    Examine dynamic range query

    I am making a dynamic query however i cannot see how to add range values dynamically, with the fluent api you do

                var criteria = _searcher.CreateSearchCriteria(IndexTypes.Content);
                criteria.Range(..)

    However I am doing 

    var criteria = _searcher.CreateSearchCriteria(IndexTypes.Content);
    IBooleanOperation query = criteria.NodeTypeAlias("Product");
    
    foreach (string key in Request.QueryString.Keys)
                    {
                        if (Request.QueryString[key]!=string.Empty){
                            //field is in lucene as eg __theme 
                            if (RangeFields.Contains(key) && !skipFlag)
                            {
                    //stuck here do i add range
                            }
                            else if(skipFlag)
                            {
                                skipFlag = false;
                            }
                            else{
                                query = query.And().Field("__" + key, Request.QueryString[key]);
                            }
                        }
                    }
    
    

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 18, 2010 @ 12:35
    Ismail Mayat
    0

    So i tried the following

                                IBooleanOperation rangeFrom = criteria.Range(key, fieldValueFrom,fieldValueTo, true, true);
                                IBooleanOperation rangeTo = criteria.Range(key, 0, fieldValueTo, true, true);

    Now how do i add those to my query object?

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 18, 2010 @ 12:40
    Ismail Mayat
    0

    Ok sorted:

                                query = query.And().Range("__" + key, fieldValueFrom, fieldValueTo, true, true);
                                query = query.And().Range("__" + fieldToName, 0, fieldValueTo, true, true);

    Now to test!!!

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft