How to refresh the indexes in solr? - search

i have changed one index in schema.xml and now want's to refresh all existing documents ..
How to do that ? i don't want to upload all documents again ...
any suggestion ?

if you changed the schema you HAVE TO reindex. After restarting Solr of course.
Updated:
If by 'adding one extra index' you mean adding one core, that core is empty so you have to add anything you need there.
If you change the way a field is analyzed, or add a field etc, you have to reindex again, your docs are not changed to reflect the change you made until you reindex

How are you indexing the data? If you are getting the data from a database you can use a data-import handler and use a delta-import query. The delta-import will only update newly added fields. Check out this link for full documentation:
http://wiki.apache.org/solr/DataImportHandler

Related

couchdb primary key workaround

I am looking for a workaround for primary key feature in couchdb. I am saving doc in json format to couchdb externally. Is there any simple way to check if value of a particular field exists?
If you try to save a document that already exists, it will be rejected unless the revision is set to match the existing revision.
Alternately, you can just try to fetch the document, either with GET or HEAD, to check if it exists. See the relevant documentation.
You could perform a mango query previous to the document creation but it will not warranty that another process create a document between the check and the creation.
This post discusses about the same issue:
How to check for duplication before creating a new document in CouchDB/Cloudant?

How to get last created document in couchdb?

How can I get last created document in couchdb? Maybe some how I can use _changes feature of couchdb? But documentation says, that I only can get list of document, ordered by first created document, ant there is no way to change order.
So how can I get last created document?
You can get the changes feed in descending order as it's also a view.
GET /dbname/_changes?descending=true
You can use limit= as well, so;
GET /dbname/_changes?descending=true&limit=1
will give the latest update.
Your only surefire way to get the last created document is to include a timestamp (created_at or something) with your document. From there, you just need a simple view to output all the docs by their creation date.
I was going to suggest using the last_seq information from the database, but the sequence number changes with every single write, and replication also complicates the matter further.

How can I remove few enties in the $UpdatedBy field in a particular documents

With out modifying the option in the database properties Advanced tab Option "Limit entries in $UpdatedBy Fields " --- How can I remove few of the $UpdatedBy field entries in documents.
I have a requirement to remove few of the $UpdatedBy field entities in one particular document.
Any suggestions ?
$ fields are usually maintained by Lotus itself. It is probably not impossible, but this post describe why it is not feasible
If it is absolutely required to do this without changing the database properties, you can consider creating a new document and copy all the items of the previous document (excluding the $ items). This new document will have a new UNID so if any documents are pointing to this document you should fix that also.
It is not possible to edit the $UpdatedBy field.
(see more discussion here)
You could use DXL to export the document without the $UpdatedBy field and then import it back in as a new document. I've used this technique successfully on entire databases where I needed to clear the history from all the documents and from all the database design elements.
The standard NotesDXLExporter NotesDXLImporter help code worked for me, and then I just added a property setting:
exporter.OmitItemNames = "updatedby"
When the documents are reimported, the $UpdatedBy field is recreated, of course, but your name is the only entry.

How to get Post with Comments Count in single query with CouchDB?

How to get Post with Comments Count in single query with CouchDB?
I can use map-reduce to build standalone view [{key: post_id, value: comments_count}] but then I had to hit DB twice - one query to get the post, another to get comments_count.
There's also another way (Rails does this) - count comments manually, on the application server and save it in comment_count attribute of the post. But then we need to update the whole post document every time a new comment added or deleted.
It seems to me that CouchDB is not tuned for such a way, unlike RDBMS when we can update only the comment_count attribute in CouchDB we are forced to update the whole post document.
Maybe there's another way to do it?
Thanks.
The view's return json includes the document count as 'total_rows', so you don't need to compute anything yourself, just emit all the documents you want counted.
{"total_rows":3,"offset":0,"rows":[
{"id":...,"key":...,value:doc1},
{"id":...,"key":...,value:doc2},
{"id":...,"key":...,value:doc3}]
}

Delete document with an empty ID

I have a CouchDB database in production. One of the documents has been edited (in Futon by an other developer).
And it's lost it's ID (don't ask me how he did it).
So now the document's id is an empty string, which makes it impossible to edit or delete via Futon.
Is there a way I could hack into CouchDB to delete that document anyway ?
I couldn't delete the document. But the database itself could be deleted.
And I couldn't reproduce the bug in locale. The other developer says he just removed the _id param and saved. I don't know what happened in CouchDB when he did it. But when I do so, it only recreates a new document (as we'd expect it to do).
So I've been using couch_docs to retrieve the datas locally.
As the id is empty, couch_docs doesn't imports it. So you don't even need to delete it manually.
Then I reimport all the records in an other database. I change the references to the database name in my config and everything works fine.
Destroying the database is not a problem even though there's an empty id.
Technically, a document ID is immutable so actually changing the _id field is not directly possible. Perhaps another document was created as a copy of the first?
A bug in CouchDB 1.1.0 allowed update functions to create empty string IDs.
A similar question asks about this and I gave a walkthrough of deleting empty ids there.
I haven't tried it but LoveSeat is supposed to be able to open and edit couchedb files...
This can be caused (and fixed!) by some error checking CouchDB was missing for _update handlers, as explained in How do you delete a couchdb document with an empty "" document id?

Resources