1

I import a CSV file to CouchDB with the correct structure.

Now I would like to search for records matching one search term in ANY of the fields. Here is an example record :

{
  "_id": "QW141401",
  "_rev": "1-7aae4ce6f6c148d82d7d6e1e3ba28542",
  "PART": {
    "ONE": "QUA01135",
    "TWO": "W/364",
    "THREE": "QUA04384",
    "FOUR": "QUA12167"
  },
  "FOO": {
    "BAR": "C40"
  },
  "DÉSIGNATION": "THE QUICK BROWN FOX"
}

Now given a search term, for example QUA04384 this record should come up. Aloso for C40. And, if possible, also for a partial match like FOX

The keys under PART and FOO can change from record to record...

2 Answers2

1

This could be a similar question. Probably you are looking for a Full Text Search mechanism.

Yo can try with couchdb-lucene or elasticseach

Juanjo Rodriguez
  • 2,103
  • 8
  • 19
0

A stupid way to do this is to build an additional field (call it 'fulltext') in each Lucene document, containing the concatenation of all other field values. (Remember to build this completely dynamically so that every single field has its contents in this additional field no matter what the original field name was.) Then you can perform your searches on this 'fulltext' field.

Mark Leighton Fisher
  • 5,609
  • 2
  • 18
  • 29
  • 1
    I thought it would make sense to use CouchDB for this kind of problem. I finally went back to MySQL... Serializing all records in a text field and doing a full text search on them. – Christian Meichtry Feb 28 '18 at 12:48