Search code examples
lucenecouchdbcloudantbigcouch

Cloudant - search index for free text search - collecting values into String VS Array


Considering documents like

{ firstName: "Jack", lastName: "Smith"}

and

{firstName: "Simon", lastName"Jackson"}

to build up a search index for "free-text" - I can do either:

for(var key in doc)
  index("default", doc[key], {"store":true});
//e.g. resulting field = default:["Jack", "Smith"]

OR

var indexString = "";
for(var key in doc)
  indexString += " " + doc[key];

index("default", indexString, {"store":true}); 
//e.g. resulting field = default:"Jack Smith"

Is there are performance / search quality difference?


Solution

  • Assuming that you are using standard analyzer, there is no any performance difference between indexing "Jack Smith", and ["Jack", "Smith"]. The Standard analyzer will break "Jack Smith" into "Jack", "Smith" anyways.

    About search quality, it depends if you want to search for the whole phrase: "Jack Smith". Both these two options will allow you to search for "Jack" or "Smith" individual queries, but only the last option will allow you to search for a phrase "Jack Smith".