I guess that’s what kept the Neo Technology — the guys behind Neo4j — busy lately: The Neo4j Spatial project supports the use of geographic data by providing utilities that simplify and support advanced capabilities like: Storage of geographic features like points, lines and polygons as graphs Indexing and querying based on location with R-trees, Q …
Tag Archives: nosql
NoSQL databases: 10 Things you Should Know About Them
NoSQL databases: 10 Things you Should Know About Them: 5 pros and 5 cons by Guy Harrison: Five advantages of NoSQL Elastic scaling Big data Goodbye DBAs (see you later?) Economics Flexible data models Five challenges of NoSQL Maturity Support Analytics and business intelligence Administration Expertise A few amendments though: Elastic scaling: part …
Usar Solr desde PHP
Solr es un servidor de búsquedas basado en Lucene que nos puede venir muy bien cuando nuestro proyecto web necesite un motor de búsqueda en condiciones, siendo una alternativa a Sphinx. Aunque está basado en Java, existe una librería que permite trabajar con ella, otra posibilidad sería utilizar Zend Search, ya que usa el formato de Lucene, aunque en una versión anterior a la que utiliza Solr, por lo que nos encontramos con incompatibilidades.
El uso de la librería es bastante sencillo:
require_once( 'Apache/Solr/Service.php' );
//
//
// Try to connect to the named server, port, and url
//
$solr = new Apache_Solr_Service( 'localhost', '8983', '/solr' );
if ( ! $solr->ping() ) {
echo 'Solr service not responding.';
exit;
}
//
//
// Create two documents to represent two auto parts.
// In practice, documents would likely be assembled from a
// database query.
//
$parts = array(
'spark_plug' => array(
'partno' => 1,
'name' => 'Spark plug',
'model' => array( 'Boxster', '924' ),
'year' => array( 1999, 2000 ),
'price' => 25.00,
'inStock' => true,
),
'windshield' => array(
'partno' => 2,
'name' => 'Windshield',
'model' => '911',
'year' => array( 1999, 2000 ),
'price' => 15.00,
'inStock' => false,
)
);
$documents = array();
foreach ( $parts as $item => $fields ) {
$part = new Apache_Solr_Document();
foreach ( $fields as $key => $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $datum ) {
$part->setMultiValue( $key, $datum );
}
}
else {
$part->$key = $value;
}
}
$documents[] = $part;
}
//
//
// Load the documents into the index
//
try {
$solr->addDocuments( $documents );
$solr->commit();
$solr->optimize();
}
catch ( Exception $e ) {
echo $e->getMessage();
}
//
//
// Run some queries. Provide the raw path, a starting offset
// for result documents, and the maximum number of result
// documents to return. You can also use a fourth parameter
// to control how results are sorted and highlighted,
// among other options.
//
$offset = 0;
$limit = 10;
$queries = array(
'partno: 1 OR partno: 2',
'model: Boxster',
'name: plug'
);
foreach ( $queries as $query ) {
$response = $solr->search( $query, $offset, $limit );
if ( $response->getHttpStatus() == 200 ) {
// print_r( $response->getRawResponse() );
if ( $response->response->numFound > 0 ) {
echo "$query
";
foreach ( $response->response->docs as $doc ) {
echo "$doc->partno $doc->name
";
}
echo '
';
}
}
else {
echo $response->getHttpStatusMessage();
}
}
También recomiendo que en el esquema de Solr añadamos el filtro de caracteres mapping-ISOLatin1Accent.txt, para que no tengamos problemas a la hora de buscar palabras acentuadas sin usar los acentos (cancion => canción).
NoSQL Guide for Beginners
NoSQL Guide for Beginners: Alexandre Porcelli has a great post for NoSQL beginners: one of the most frequent question that people use to ask me about nosql is: what is the best nosql tool that enables me start with using my programming language (java, .net, php, python, etc..)? its almost impossible to have a quick answer ‘cos it involves many thin …
Designing Web Applications for Scalability
I can’t even count the number of times that I’ve heard this phrase: “don’t worry about scaling your web application, worry about visitor (or customer) acquisition.” My response to this is always that you don’t need to choose one or the other, you can do both! In this post, I’m going to go over some of the strategies I’ve used to architect web appli …
What is HyperGraphDB?
Recently we’ve seen a lot of activity in the graph database world. Better understanding the space will help us make smarter decisions, so I’ve decided to reach out to the main players in the market and run a series of interviews about their projects …
NoSQL Databases and Security
NoSQL Databases and Security: Jeff Darcy writes about NoSQL systems’ security (actually the lack of): Most NoSQL stores have no concept of security. […] Mostly it falls into two categories: encryption and authentication/authorization (collectively “a …
Usar Neo4j con PHP usando REST
neo4j es una base de datos de grafos que puede ser muy útil para aplicaciones tipo redes sociales. El problema para los que usamos PHP es que neo4j está en Java y para usarlo desde PHP o se una un bridge que conecte con Java o usar la versión REST de neo4j y acceder vía web.
Su uso es muy sencillo:
$graphDb = new GraphDatabaseService('http://localhost:9999/');
$node = $graphDb->createNode();
$node->message = "Hello, ";
$node->blah = "blah blah";
$node->save();
Se le puede añadir todas las propiedades que se quieran, que se transforman en un array de datos que luego se enviarán en json.
El único problema que tiene esta librería es que no genera índices, aunque es muy sencillo modificar, ya que tan solo es necesario añadir una llamada para generar el índice:
HTTPUtil::jsonPostRequest($this->_neo_db->getBaseUri().'index/node/clave/'.$this->_data['clave'], $this->_neo_db->getBaseUri().'node/'.$this->_id);
siendo ‘clave’ lo que queramos añadir como índice. También es necesario modificar HTTPUtil::jsonRequest para que cuando $data no sea un array no se codifique en JSON.
Enlaces rápidos (04-06-2010)
Más enlaces rápidos sobre NOSQL, para variar:
- NoSQL is About…
- NoSQL Graph Database feature comparison
- Cassandra NOSQL EU 2010 – Twitter: “Hace 15 meses se tardó 2 semanas en hacer un ALTER TABLE de la tabla de statuses [tweets]”
- NoSQL in the Enterprise
- NOSQLEU – Graph Databases and Neo4j
- Dealing data deluge
- Yahoo! Cloud Serving Benchmark (YCSB)
- Running Hadoop MapReduce With Cassandra NoSQL
- NoSQL at Twitter
- MySQL vs MongoDB
- Mashups with the Facebook Graph API and Neo4j
- NoSQL Graph Database Comparison
- Cassandra By Example
- Scalability of the Hadoop Distributed File System
- A NoSQL Use Case: URL Shorteners
- Cassandra Webconsole
- Learning NoSQL from Twitter’s Experience
- NoSQL Databases
- InfiniteGraph: the distributed graph database
- HTML5 Custom Data Attributes (data-*)
- Simple Document Versioning with CouchDB
Rediska: librería PHP para trabajar con Redis
Porque no todo el NOSQL es Cassandra, es importante tener a mano cualquier librería que podamos usar en el caso de trabajar con NOSQL. Rediska es una librería que permite trabajar con Redis, la cual tiene las siguientes características:
- Soporte para múltiples servidores
- Hashing consistente, crc32 o algoritmo propio para distribución de claves
- Trata las claves como objetos
- Usa las Lists, Sets y Sorted como arrays de PHP
- Integración con Zend Framework y Symfony
- Buena documentación