Skip to content

Commit

Permalink
Make search index compatible with Search 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
willholley committed Sep 17, 2013
1 parent 3484b0d commit 8414867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
5 changes: 3 additions & 2 deletions _attachments/search.js
Expand Up @@ -26,10 +26,11 @@

if (!cache[query]) cache[query] = { rows: [], loading: true, offset: 0 }

return $.get('../../_search', { q: query, default_field: 'all', include_docs: true, limit: ROWS, skip: cache[query].rows.length }, function(results) {
return $.get('../lucene/_search/searchapp', { q: 'all:' + query, include_docs: true, limit: ROWS, bookmark: cache[query].bookmark }, function(results) {
cache[query] = {
rows: cache[query].rows.concat(results.rows),
total_rows: results.total_rows
total_rows: results.total_rows,
bookmark: results.bookmark
}
return callback(cache[query])
})
Expand Down
14 changes: 4 additions & 10 deletions _docs/lucene.json
@@ -1,14 +1,8 @@
{
"_id":"_design/lucene",
"language":"java",
"views" :
{
"index" : {
"map": {
"classname": "com.cloudant.indexers.DefaultSearch"
},
"reduce": "_count",
"comment": "This indexes all json values in the document and places them in a single searchable field name all as well as their named field"
"_id": "_design/lucene",
"indexes": {
"searchapp": {
"index": "function(doc){\n for(var key in doc){\nif(doc.hasOwnProperty(key)){\nif(key[0] === \"_\") continue;\n index(\"all\", doc[key]);\n index(key, doc[key]);\n}\n}\n}"
}
}
}

0 comments on commit 8414867

Please sign in to comment.