How to create an index in orientdb (native java api) - orientdb

I am getting the following warning when the graph starts to grow:
'bertex = false' fetched more than 50000 records: to speed up the execution, create an index or change the query to use an existent index
Is there a way to create the index from the java api?
I do not seem to find the right javadocs.
Thanks a lot!

Try this:
graph.createKeyIndex("name", Vertex.class, new Parameter("type", "UNIQUE"));
For more information take a look at this link: http://orientdb.com/docs/2.1/Graph-Database-Tinkerpop.html#using-indices
Hope it helps.
Regards

Related

How to query from ListColumn[String] in cassandra using phantom

I am new to cassandra (started learning on my own interest few days back) and looking for help for the below problem.
I have a Cassandra table "User" and a ListColumn "interests extends ListColumn[String]".
Now, I want to fetch all users with an interest, say "playing".
like: select from user where interests.contains("playing")!
I scanned through the ListColumn api but not able to find any. Also, searched in google but no such helpful posts.
Any help guys please... Thanks in Advance :)
So there is contains among operators and here is an example how to use it. It looks like that it should work as any other operator, so just go for database.userTable.select.where(_.interests contains "playing").fetch() - of course, depending on your conventions.
This is possible with a secondary index on a collection column, which only works with a Set column, and not with a List.
Bottom line:
object interests extends SetColumn[String](this) with Index[Set[String]]
And then you can execute the following:
select.where(_.interests contains "test").fetch()
You can also use multiple restrictions if you allow filtering.
select.where(_.interests contains "test")
.and(_.interests contains "test2")
.allowFiltering()
.fetch()
The above will only match if both interests are found in a record.

How to run the update query in JPA

I am playframework application developer. I am using createNativeQuery method in jpa to extracting values from tables through select query. I need to use update query. What i have to do and what will be the return type of that method. Please anyone help me. Thanks in advance..
if i use like this it showing error..
Query query=JPA.em().createNativeQuery("update truck set flag='YES' where shipment_upc=:EAN_code");
query.setParameter("EAN_code", EAN_code);
System.out.println(query.getSingleResult());
Use createNativeQuery with your update- query and you will get back a Query- Object.
On it use executeUpdate and you get back the number of updated datas.

Sphinx search debugging

We use Sphinx Search at work but and I am having an issue with a new index I'm setting up. Does anyone know of a tool or technique that so I can look at the data stored in Sphinx?
Basically I want to do something like - "show me the first 5 records in index 'X'", just to be sure that it is actually storing data. At the moment I'm about 90% sure that my query code is correct but have no way of knowing that my index is correct.
Cheers
*SELECT * FROM index_name* on Sphinx side should give you a list of IDs. This required MySQL protocol support to be enabled in Sphinx conf file:
listen = 9306:mysql41
To Find Ids in index, you can do this:
/usr/local/sphinx/bin/indextool -c /usr/local/sphinx/etc/sphinx.conf --dumpdocids indexname

Get total record count for a query in zend lucene search?

HI
I have used "setResultSetLimit(1000)" method to limit results to 1000 records. The good thing is It helps to save server resources, but there is noway to get full record count for a query. Is any one know how to get full hit count?
TX
Its not possiblie within my tries...
I suggest u to make a full search store results making a cache file maybe or session and use zend_paginator array adapter
The answer is so easy or I didn't understand the question ?
$results = $index->find("saerch term");
echo count($results); // you will get count

Zend Framework. The best solution to calculate rows in the table

I'm newbie in ZF and have some stupid question:
What's the best solution to calculate rows in the table if I work with inherited object of Zend_Db_Table_Abstract class?
For my first web application I use QuickStart tutorial (link text) so if I want to calculate count of rows in the table in controller the simplest solution will be something like that:
$guestbooks = new Default_Model_GuestBook();
$count = count($guestbooks->fetchAll());
But I don't think that fetchAll() is the best solution just to calculate rows in the table because GuestBook table can be really huge. May be it is possible to use something much more easy and simple?
I found in manual that it is possible to work direct with DB Adapter (like $db->query("SELECT COUNT(*) FROM GuestBook");), but in QuickStart tutorial I haven't got that object in controller and I really don't want to create it only for one simple action.
Will be waiting for suggestions!
Thanks
Your model already contains DB Adapter because it also works with DB. You can get access to DB Adapter using getAdapter() method.
$questbooks->getAdapter()->query("SELECT COUNT(*) FROM GuestBook");