How to perform a Prefix query with Elastica

I'm attempting to create an autocomplete search using Elastica and
Elastic Search (more specifically, FOSElasticaBundle for Symfony2).

I've created a simple index, populated it with objects.

A basic search works, ie:

$finder = $this->container->get('fos_elastica.finder.search.person');
$results = $finder->find('Mike');

I'm having some trouble getting my prefix query to work though and I can't
find any examples online. Here's what I'm trying:

$finder = $this->container->get('fos_elastica.finder.search.person');
$prefixQuery = new \Elastica\Query\Prefix();
$prefixQuery->setPrefix('nameFirst','Mik');
$results = $finder->find($prefixQuery);

It doesn't kick any errors, but just doesn't return any results.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d04ca78b-a739-40a3-8758-033ad47450c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Any help?

El miércoles, 24 de septiembre de 2014 12:23:00 UTC+2, Javier Garcia
escribió:

I'm attempting to create an autocomplete search using Elastica and
Elastic Search (more specifically, FOSElasticaBundle for Symfony2).

I've created a simple index, populated it with objects.

A basic search works, ie:

$finder = $this->container->get('fos_elastica.finder.search.person');
$results = $finder->find('Mike');

I'm having some trouble getting my prefix query to work though and I can't
find any examples online. Here's what I'm trying:

$finder = $this->container->get('fos_elastica.finder.search.person');
$prefixQuery = new \Elastica\Query\Prefix();
$prefixQuery->setPrefix('nameFirst','Mik');
$results = $finder->find($prefixQuery);

It doesn't kick any errors, but just doesn't return any results.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bff3bdd1-7f3c-4b75-bc54-92483d42e650%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Can tu print the query that your code translates to? Basically your prefix query could be accomplished using wildcards?

On Sep 25, 2014, at 4:50 AM, Javier Garcia tirengarfio@gmail.com wrote:

Any help?

El miércoles, 24 de septiembre de 2014 12:23:00 UTC+2, Javier Garcia escribió:

I'm attempting to create an autocomplete search using Elastica and Elastic Search (more specifically, FOSElasticaBundle for Symfony2).

I've created a simple index, populated it with objects.

A basic search works, ie:

$finder = $this->container->get('fos_elastica.finder.search.person');
$results = $finder->find('Mike');

I'm having some trouble getting my prefix query to work though and I can't find any examples online. Here's what I'm trying:

$finder = $this->container->get('fos_elastica.finder.search.person');
$prefixQuery = new \Elastica\Query\Prefix();
$prefixQuery->setPrefix('nameFirst','Mik');
$results = $finder->find($prefixQuery);

It doesn't kick any errors, but just doesn't return any results.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/bff3bdd1-7f3c-4b75-bc54-92483d42e650%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Concurso "Mi selfie por los 5". Detalles en http://justiciaparaloscinco.wordpress.com

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/E0F3A97D-4DF3-4668-A9BC-BCD5A02442E5%40uci.cu.
For more options, visit https://groups.google.com/d/optout.