For some reason I can't find a document when I search by the id of a nested document. I can perform other finds easily enough so these two work:
User.findOne({"_id" : some_id}, function(err,user){}
User.findOne({"arrayOfNestedDocs.value":someValue}, function(err,user){}
But finding by id of nested doc doesn't work:
User.findOne({"arrayOfNestedDocs._id" : some_id}, function(err,user){}
I can perform the search in a mongo shell so but not via mongoose. Any ideas would be helpful.
I've added it as an issue in the project
If you're trying to find an embedded document then the syntax is:
User.findOne({_id: id}, function(err, user) {
var embeddedDoc = user.embeddedDocs.id('embeddedDocId');
});
Related
I have a RavenDB Index that I am using to delete a bunch of documents at one time. I would like to know home many documents were actually deleted after the operation is done, however I can't figure out how to get that information from a DatabaseCommands call. For a RavenQuery/DocumentQuery you can use the out Statistics, but I haven't found anything for the DatabaseCommands.
I did find a RetrieveDetails flag as part of the BulkOperationsOptions but I'm not sure how to actually see the details. Here is what my query looks like
var op = connection.Store.DatabaseCommands.DeleteByIndex(
"Store/ByExpiration",
new IndexQuery
{
Query = "Expiration:yes"
},
new BulkOperationOptions
{
AllowStale = false,
RetrieveDetails = true
});
op.WaitForCompletion();
At this point I am not sure how to get the details once the operation has completed. Has anyone else figured out how to get these details?
The result is returned as a RavenJToken in WaitForCompletion.
var result = op.WaitForCompletion();
The documentation isn't clear on this.
Hint: When I can't find examples in the documentation I look at the RavenDB source code unit tests for examples, e.g. the ShouldRetrieveOperationDetailsWhenTheyWereRequested unit test.
Category Name
|
Geograpy (8)
Study Db (18)
i am implement my own advance search in alfresco. i need to read all files which related with particular category.
example:
if there is 20 file under geograpy, lucene query should read particular document under search key word "banana".
Further explanation -
I am using search.lib.js to search. I would like to analyze the result to find out to which category the documents belong to. For example I would like to know how many documents belong to the category under Languages and the subcategories. I experimented with the Classification API but I don't get the result I want. Any Idea how to go through the result to get the category name of each document?
is there any simple method like node.properties["cm:creator"]?
thanks
janaka
I think you should specify more your question:
Are you using cm:content or a customized content?
Are you going to search the keyword inside the content of the file? or are you going to search the keyword in a specific metadata(s)?
Do you want to create a webscript (java or javascript)?
One thing to take in consideration:
if you use +PATH:"cm:generalclassifiable/...." for the categorization in your lucene queries, the performance will be slow (following my experince)
You can use for example the next query to find all nodes at any depth below /cm:Languages:
var results = search.luceneSearch("+PATH:\"cm:generalclassifiable/cm:Languages//*\");
Take a look to this url: https://wiki.alfresco.com/wiki/Search#Path_Queries
Once you have all the elements, you can loop all, and get to which category below. Of course you need to create some counter per each category/subcategory:
for(i = 0; i < results.length; i++){
var node = results[i];
var categoryNodeRef = node.properties["cm:categories"];
var categoryDesc = categoryNodeRef.properties["cm:description"];
var categoryName = categoryNodeRef.properties["cm:name"];
}
This is not exactly the solution, but can be a useful idea to start.
Sorry if it's not what you're asking for, I have just arrived from my holidays.
I need to know can there be a tooltip populated with data from database to be displayed in the tooltip.
something like the tooltip should contain
name stauts
abc active
xyz active
pqr active
name and status are retrived from db
I need this tooltip onmouseover, am using CJSON decoded to render the content
i did go google but hardly did find that i would throughly understand and implement.
can anyone out there has any ideas for what am looking.
There is a extension named yii-bootstrap, which described clearly here.
For using tooltip easily in this extension, just look here.
I use cluetip for this. Its not related to Yii but will give you some idea :
JS
function renderInfoTips(opts){
var elements=$('#'+opts.form).get(0).elements;
for(i=0; i<opts.tips.length;i++){
$(elements[opts.tips[i].field]).parent().prepend(opts.tips[i].tip);
}
var clue_opts={arrows:true,splitTitle: '|',closePosition: 'title',sticky:true,dropShadow:false,mouseOutClose:true,
onShow:function(ct, ci){
if(!$.browser.webkit) $(ct).css('top',$(ct).position().top- 30+'px');
}
}
$('#'+opts.form).find(".infotip").cluetip(clue_opts);
}
PHP
function setInfoTipsJavascript($form_id,infotips){
if (count($this->infotips) <1 ) return '';
//get all tip names
$names_csv=join(',',array_keys(infotips));
//get tips details from db
$query="select name, description from infotips where FIND_IN_SET(name ,'$names_csv')";
//run the query, in Yii you have to use InfoTipsModel , I have skipped that portion
//$infotipS , lets say this is query object
$tips=array();
while($tip=$infotipS->Assoc()){
$this->infotips[$tip['name']]['tip']="<a href='javascript:void(0)' class='infotip' title='|{$tip['description']}'> </a>";
$tips[]=$this->infotips[$tip['name']];
}
$tips=json_encode($tips);
$script="\nrenderInfoTips({\"form\":'{$form_id}', \"tips\":{$tips}});\n\n";
echo $script;
}
I am sharing this hoping this will give u some idea. Its obvious you have to : create infotips table, a model for that, and create a widget etc to fetch infotips related to your form fields . As someone suggested, if you are using Bootstrap, you have better way to do that.
I am using Umbraco and came across Lucene. I found a lot of code and articles on Lucene, but I still can't build an acceptable search.
I have a number of fields to search from, eg. "nodeName" and "bodyText"
What I need:
When I search for "men shoes", it should only return results that have both "men" and "shoes", but also return a page where the nodeName only has "shoes" and the bodyText only has "men".
When I search for "shoes", I want results containing "shoe" or "shoes." but not "hoes" if possible
Boost the nodeName field
Get a snippet of bodyText that contains the matched word(s)
Highlight the matched words on both the page name and the snippet of the bodyText
Has anyone ever done this?
This might get you started.
var manager = ExamineManager.Instance;
var searcher = manager.SearchProviderCollection["YOURSearcher"];
var query = manager.SearchProviderCollection["YOURSearcher"].CreateSearchCriteria(BooleanOperation.Or)
.Field("nodeName", keywords.Boost(10))
.Or().Field("nodeName", keywords.Fuzzy())
.Or().Field("bodyContent", keywords.Boost(5))
.Or().Field("otherField", keywords.Boost(3));
var results = searcher.Search(query.Compile());
The code by Jonathan Lathigee works, it's the most google-like I could find so far
http://our.umbraco.org/forum/developers/extending-umbraco/19329-Search-multiple-fields-for-multiple-terms-with-examine?p=0
I am using the Sourcerer plugin to use PHP code inside my articles. I would like to use the Joomla API/framework inside my article to dynamically set the HTML meta tags and other stuff. I found the setHeadData method that should allow me do that but I have simply no idea as to how calling it.
[Q] Can someone give me 1 example or point me to a tutorial that would help me get started on using that joomla API/framework please?
Answer
Based on the numerous feedbacks all pointing in the same direction, using a content plugin to modify the head data is properly better than doing this via an article. If like me you want to do this in an article here is what I did:
(1) I used the snippet provided by ezpresso to set the head data inside my article.
(2) I modified the libraries/joomla/document/html/renderer/head.php file to change the way the head data was set there.
For instance you can set the title meta tag at step (1) and then at step (2) replace the following line:
$strHtml .= $tab.'<title>'.htmlspecialchars($document->getTitle()).'</title>'.$lnEnd;
with this one:
$strHtml .= $tab.'<title>'.htmlspecialchars($document['metaTags']['standard']['title']).'</title>'.$lnEnd;
You might also want to look into libraries/joomla/document/html/renderer/head.php to do some more cleanup in the head, like getting rid of the generator meta tag that Joomla inserts.
Here is the source code of the method you are referring to:
/**
* Set the html document head data
*
* #access public
* #param array $data The document head data in array form
*/
function setHeadData($data)
{
$this->title = (isset($data['title'])) ? $data['title'] : $this->title;
$this->description = (isset($data['description'])) ? $data['description'] : $this->description;
$this->link = (isset($data['link'])) ? $data['link'] : $this->link;
$this->_metaTags = (isset($data['metaTags'])) ? $data['metaTags'] : $this->_metaTags;
$this->_links = (isset($data['links'])) ? $data['links'] : $this->_links;
$this->_styleSheets = (isset($data['styleSheets'])) ? $data['styleSheets'] : $this->_styleSheets;
$this->_style = (isset($data['style'])) ? $data['style'] : $this->_style;
$this->_scripts = (isset($data['scripts'])) ? $data['scripts'] : $this->_scripts;
$this->_script = (isset($data['script'])) ? $data['script'] : $this->_script;
$this->_custom = (isset($data['custom'])) ? $data['custom'] : $this->_custom;
}
It is implemented in a JDocumentHtml class, which is located in a libraries/joomla/document/html/html.php directory.
Below is the links to some of the examples of how to use it:
setHeadData difference between j1.5 and j1.6
Remove Mootools From Joomla Header
I guess you may call the setHeadData method like this:
$doc =& JFactory::getDocument();
$options = $doc->getHeadData();
$options['metaTags'] = array("tag1", "tag2", "tag3"); // you may change the meta tags here
$doc->setHeadData($options);
Putting PHP in the article is not a very good way to accomplish what you are trying to do. Joomla frameworks has an order of operation that determines when various functions and plugins run. Due to the order of operation, there are numerous functions that will happen after an article is rendered, probably negating any changes you make from within the article. You would be better off either using an extension to handle titles and meta tags rather than trying to do it inside the article.