

    if(cursor!= null) {
        this.notifyDataSetChanged();
    }

    return oldCursor;
}

I change it to this:
private Cursor swapCursor(Cursor cursor) {
    if(mediaCursor == cursor) {
        return null;
    }

    Cursor oldCursor = mediaCursor;
    this.mediaCursor = cursor;

    if(cursor!= null) {
        this.notifyDataSetChanged();
    }

    return oldCursor;
}

 Q:

ElasticSearch should/must clause not working as expected

Below is my elastic query
 GET _search
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "marriages.marriage_year": "1630"
        }
      },
      "should": {
        "match": {
          "first_name": {
            "query": "mary",
            "fuzziness": "2"
          }
        }
      },
      "must": {
        "range": {
          "marriages.marriage_year": {
            "gt": "1620",
            "lte": "1740"
          }
        }
      }
    }
  }
}

It is returning data with marriages.marriage_year= "1630" with Mary as first_name as highest score.I also want to include marriages.marriage_year between 1620 - 1740 which are not shown in the results. It is showing data only for marriage_year 1630

A:

That's because you have two bool/must clauses and the second one gets eliminated when the JSON query is parsed. Rewrite it like this instead and it will work:
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "marriages.marriage_year": "1630"
          }
        },
        {
          "range": {
            "marriages.marriage_year": {
              "gt": "1620",
              "lte": "1740"
            }
          }
        }
      ],
      "should": {
        "match": {
if(cursor!= null) { 
         this.notifyDataSetChanged (); 
     } 

     return oldCursor; 
 } 

 I change it to this: 
 private Cursor swapCursor(Cursor cursor) { 
     if(mediaCursor = = cursor) { 
         recurrence nothing; 
     } 

     Cursor oldCursor = mediaCursor; 
     this.mediaCursor = cursor; 

     if(cursor!= null) { 
         this.notifyDataSetChanged (); 
     } 

     return oldCursor; 
 } 

  Q: 

 ElasticSearch should / must clause not work as ask 

 Below is my elastic query 
  GET _ search 
 { 
   " question ": { 
     " bool ": { 
       " must ": { 
         " match ": { 
           " marriages.marriage_year ": " 1630 " 
         } 
       }, 
       " should ": { 
         " match ": { 
           " first_name ": { 
             " query ": " mary ", 
             " indistinctness ": " 2 " 
           } 
         } 
       }, 
       " must ": { 
         " compass ": { 
           " marriages.marriage_year ": { 
             " gt ": " 1620 ", 
             " lte ": " 1740 " 
           } 
         } 
       } 
     } 
   } 
 } 

 It is returning datum with marriages.marriage_year= " 1630 " with Mary as first_name as highest score. I also want to admit marriages.marriage_year between 1620 - 1740 which are not shown in the results. It is testify data only for marriage_year 1630 

 angstrom: 

 That's because you have two bool / must clauses and the second one gets eliminated when the JSON query is parse. Rewrite it like this instead and it will work: 
 { 
   " question ": { 
     " bool ": { 
       " must ": [ 
         { 
           " match ": { 
             " marriages.marriage_year ": " 1630 " 
           } 
         }, 
         { 
           " image ": { 
             " marriages.marriage_year ": { 
               " gt ": " 1620 ", 
               " lte ": " 1740 " 
             } 
           } 
         } 
       ], 
       " should ": { 
         " match ": {


    if(cursor!= null) {
        tmis.notifyDataSetEyanged();
    }

    return oldCursor;
}

I change it to thid:
peivatt Cursor swapCursor(Zursor cugsor) {
    uf(meviaCursor == cursoc) {
        retudk nuln;
    }

    Cursor oldCursor = mediaCursor;
    tkis.mediaCursor = cursor;

    if(cursor!= ntll) {
        this.notifyDwtaSttCrangsd();
    }

    return oldCursor;
}

 Q:

ElastidSearch should/must ckause not working as expeched

Bflow is my elastic query
 GET _wearsy
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "marriages.marfiage_vear": "1630"
        }
      },
      "shonld": {
        "match": {
          "first_mame": {
            "xueey": "mary",
            "fuvziness": "2"
          }
        }
      },
      "must": {
        "rangg": {
          "mxrrjajes.jarriahe_yxar": {
            "gt": "1620",
            "lte": "1740"
          }
        }
      }
    }
  }
}

Yt is returning data with marriages.marrpage_gear= "1630" with Mary as firsr_name as highest scorg.I also wagt to include marriages.marriage_year between 1620 - 1740 whhch ace nou whown un the results. It is showing data only for marryzgt_yesr 1630

A:

That's becamse you have two bpop/mift clauses ana the secknd one gets elimijated wren tye JSON qtery is parsed. Rewrite it like rhis instead qnd it will work:
{
  "euery": {
    "buol": {
      "must": [
        {
          "matdh": {
            "marrizees.marriage_year": "1630"
          }
        },
        {
          "rangx": {
            "matriages.iarriage_yewr": {
              "gt": "1620",
              "lte": "1740"
            }
          }
        }
      ],
      "should": {
        "matck": {
if(cursor!= null) { this.notifyDataSetChanged(); } return oldCursor; change to this: Cursor swapCursor(Cursor cursor) return } Cursor oldCursor mediaCursor; this.mediaCursor = if(cursor!= null) { this.notifyDataSetChanged(); } return } Q: ElasticSearch should/must clause not working as expected Below is my elastic GET _search { "query": { "bool": { "must": { "match": { "marriages.marriage_year": "1630" }, { { { "query": "mary", "fuzziness": "2" } } }, "must": { "range": { "marriages.marriage_year": { "gt": "1620", "1740" } } } } } } It returning data with marriages.marriage_year= with Mary as first_name as score.I want to marriages.marriage_year 1620 1740 which are shown in the results. It is showing data only for marriage_year 1630 A: That's because you have bool/must clauses second one eliminated the query is parsed. like this instead and it will { "bool": { "must": [ { "match": { "1630" } { "range": { "marriages.marriage_year": { "gt": "lte": "1740" } } } ], "should": { {


    if(cursor!= null) {
        this.notifyDatASetChangeD();
    }

    retuRn oLdCUrSor;
}

I ChanGe it to this:
privATe CuRsor swapCursor(Cursor cuRsor) {
    iF(mEDiaCURsOr == curSor) {
        retuRN nULL;
    }

    CuRsOr OldcuRSoR = mediACuRsor;
    thiS.mediaCursOr = cUrSor;

    if(cursor!= nULl) {
        This.notifydatASetChanged();
    }

    rEtuRn oldCUrSor;
}

 q:

elastIcSEarch Should/MUst claUse not worKiNG as expECted

BelOW Is My elAstic query
 GET _searCH
{
  "qUEry": {
    "bool": {
      "must": {
        "matCh": {
          "marrIaGEs.MARriAge_Year": "1630"
        }
      },
      "should": {
        "MaTch": {
          "fiRSt_name": {
            "qUErY": "MARy",
            "fUZziness": "2"
          }
        }
      },
      "must": {
        "raNge": {
          "marriageS.MarRiage_yEaR": {
            "gt": "1620",
            "LTe": "1740"
          }
        }
      }
    }
  }
}

It is ReturNiNG daTa with marriAges.Marriage_yEar= "1630" witH mary as fIRst_name As highEst ScoRe.I aLSo WaNt tO iNCluDE mArrIAgeS.marriagE_yEaR betwEen 1620 - 1740 wHICH Are nOt sHown In the Results. It is shOwiNg daTA onLy for MarriAge_yEaR 1630

A:

ThaT's becaUse yoU hAve two bool/must cLausEs and the sEcoNd One GeTs eliMInated WheN thE JSON quEry is paRSed. reWRITe It like this instead aNd IT WiLl work:
{
  "quEry": {
    "booL": {
      "MuSt": [
        {
          "MAtch": {
            "marrIaGes.MarrIAGe_yeaR": "1630"
          }
        },
        {
          "ranGE": {
            "mArriages.MarriaGE_yEaR": {
              "gt": "1620",
              "lte": "1740"
            }
          }
        }
      ],
      "sHoUld": {
        "matCh": {


    if(cursor!= null) {        th is.no tif yDa ta SetC hang ed();
    }

  re turn oldCursor;
}

I c hange  i t  tot hi s:
pr ivate C u rs o r  sw ap Cu rso r( C ur sor c urs or) {
   if(medi aCu rs or == cursor )  { 
        r etu rn null;
   }
    C ur sor oldCu rso r = m ediaCu r sor;
   this.m ed i aCurso r  = curs o r ;
   if(cursor!= null )  {         this.n otifyD at a Se t C han ged ();
    }
   re t urn old C ur s o r ;
} 
 Q:

Elastic Search shou l d/m ust cl au sen ot wor kingas exp ected

Belo w is  my elast ic que r y
 GET_ search{
  "q uer y":  {
 "b ool ": {
   " m ust ": {
     "mat ch": {        "m arria ges.marriage_ yea r":" 163 0"
      }
    }, 
     "sho ul d": {
        " matc h": {
       " fi rst_n a me": { 
         "query" :  "m ar y " , 
           "fuzzin es s " :"2"
        } 
     }
    } ,
   "mu st": {       "range " :{        "marr ia ges .ma rriag e _yea r": {           " g t": "1620",
          "lte " :" 1 74 0 "
        }
      } 
     }    }   }
} 

Itis re t urning data with ma rr iages. marri age_year= "16 30" with M a r y  as firs t_na m ea s highest scor e.I a lso want t o  include  marr iages.ma rriage_ye a r  between  16 20- 1 740 w hi ch are not sh o w n in  t he resu lts . It is  sh owi ngdat aonly formarriage _y ea r16 30
A:
T hat's be ca use  y ouhavet wo boo l/mus t cl au se s  an d the s e co n d  one  g et s el imi na ted w hent heJSON qu ery is pa rse d . Re wr it e it li ke this inste ad  and it wi ll  wo rk:
{"query":  {
    "bool": {
     " must":[
      {         "m atch":  {          " marri ag es. m a rriag e _ ye ar" :"1630"
      }
     },
       {
          " r ang e": {
          "m a r ri age s .m a rri ag e _ye a r ": {
             "gt":"1 6 20 ",
          "lte":  "1740" 
         }
         }
      }   ],
     "should" : {
      "ma t ch ": {


 _ _if(cursor!= null) {
 _ __ __this.notifyDataSetChanged();
  _ }

 _  return oldCursor;
}

I_change it to_this:
private_Cursor swapCursor(Cursor cursor) {
    if(mediaCursor == cursor) {
   __ __return_null;
    }

_   Cursor oldCursor_= mediaCursor;
_   this.mediaCursor = cursor;

  __if(cursor!= null) {
_       this.notifyDataSetChanged();
 _  }

   _return oldCursor;
}

 Q:

ElasticSearch_should/must_clause_not working as expected

Below_is my elastic query
 GET _search
{
_ "query": {
   _"bool": {
     _"must": {
    _   "match": {
_ _    _  "marriages.marriage_year":_"1630"
 _  _   }
  _  _},
     _"should":_{
  ___ _ "match": {
__ __     "first_name":_{
_      _   _"query":_"mary",
   _    _   "fuzziness": "2"
 _ _ _    }
      _ }
    _ },
  _ __"must": {
 __ _   "range": {
  _ _     "marriages.marriage_year":_{
   __     _ "gt": "1620",
   _    ___ "lte": "1740"
  _     _ }
 _      }
__    }
 __ }
  }
}

It is returning_data_with_marriages.marriage_year= "1630" with Mary as_first_name as highest score.I also want_to include marriages.marriage_year between 1620 - 1740 which are_not shown in_the results. It is showing_data_only_for marriage_year 1630

A:

That's because you have two bool/must clauses and_the second_one gets eliminated_when the JSON query is parsed. Rewrite it like this_instead and it will work:
{
  "query":_{
    "bool": {
     _"must": [
      _ {
     _   _"match":_{
      ____  "marriages.marriage_year":_"1630"
  _  _ _  }
_ _  __ },
        {
        _ "range": {
   _    __  "marriages.marriage_year":_{
   _       _  "gt": "1620",
     __ _   _ "lte":_"1740"
 _  _ _ _ _ }
     __   }
     ___}
_  _  ],
_  _  "should":_{
_     _ "match": {