Need to know how to search in ES using c# searching in arrays -


hello newbie on elasticsearch , need help. i'm working c# (thought use queryraw in string think...). below scenario:

data

{     "id": "1",     "title": "small cars",     "tagscolours": ["grey",     "black",     "white"],     "tagscars": ["suzuki",     "ford"],     "tagskeywords": [] }, {     "id": "2",     "title": "medium cars",     "tagscolours": [],     "tagscars": ["vw",     "audi",     "peugeot"],     "tagskeywords": ["sedan"] }, {     "id": "3",     "title": "big cars",     "tagscolours": ["red",     "black"],     "tagscars": ["jeep",     "dodge"],     "tagskeywords": ["van",     "big"] } 

objective

id' apply filters on tags columns based on users' selection. values populated in tagsxxx array columns withselected values.

  • if parameter array value not empty result should contain @ least 1 instance. same every parameter array. more parameters have values, more specific search should done
  • if @ least there's 1 value coming parameter matches amongst values in document's tag column array, document. if there's value on tagsxxx array should take account.
  • if tag parameter array has no values, disregard filter

desired responses

a) if user select 1 tag color (i.e= black) formatted below:

{     id: "",     title: "",     tagscolours: ["black"],     tagscars: [],     tagskeywords: [] } 

i'd documents id=2 , id=3 since have black in tagscolours , disregard tagscars , tagskeywords since there no values on parameters

b) if user select 2 diff tags (i.e= colour=black , cars= audi, , mercedez benz) formatted below:

{     id: "",     title: "",     tagscolours: ["black",     "yellow"],     tagscars: ["audi",     "mercedes benz"],     tagskeywords: [] } 

i'd documents id=2 since found black on tagscolours , found audi in tagscars, , should not pull document id=1 because when black on tagscolours, none of paramters values (audi, mercedez benz) on tagscars values

hello everyone, i'm having issues when trying search on elasticsearch , in arrays values, , when parameters have no values. if helpe me on i'd appreciatte. did this:

termsquery = query<structureddata>.terms(t => t.field(f =>f.tagscolours).terms(datatosearch.tagscolours)); termsquery = termsquery && query<structureddata>.terms(t => t.field(f =>f.tagscars).terms(datatosearch.tagscars)); 

and stopped here (did not add third filter) because not mix 2 filters datatosearch has values parameters (same structure object, cause .search makes me here .search()

var settings = new connectionsettings(node);  var response = new elasticclient(settings) .search<structureddata>( s => s.allindices() .alltypes() .from(0) .size(50) .query(_ => termsquery) ); 

but i'm having problems when using more 1 filter.. ideas? ".terms" correct property?

if using regular mappings on es 5 > results want. if not need change mapping.

 querycontainer query = null;              if(datatosearch.tagscolours != null && datatosearch.tagscars.length > 0)             {                 query = query<structureddata>.terms(t=>t.field("tagscolours.keyword").terms(datatosearch.tagscolours));             }              if(datatosearch.tagscolours != null && datatosearch.tagscars.length > 0)             {                 var q =  query<structureddata>.terms(t=>t.field("tagscars.keyword").terms(datatosearch.tagscars));                 query = query == null ? q : query && q;              }              if(datatosearch.tagskeywords != null && datatosearch.tagskeywords.length > 0)             {                 var q =  query<structureddata>.terms(t=>t.field("tagskeywords.keyword").terms(datatosearch.tagskeywords));                 query = query == null ? q : query && q;              } 

the problem having term query done on non-analyzed value , default text fields use standard analyzer. of 5 added keyword sub field uses keyword analyzer places terms , can search raw values. standard analyzer dose tokenization words , lowercases terms unable find audi because term audi. if want lowercase input string not solve mercedes benz problem since in standard terms became mercedes benz terms 2 terms instead of 1 in other words terms return results if put mercedes or benz not mercedes benz. if want da case insensitive search match query need add custom analyzer.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -