Skip to content

Commit

Permalink
Use the optional "fields" attribute, and regenerate the markdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
holophrastic committed Jan 25, 2012
1 parent db07dc8 commit 78cb625
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
33 changes: 16 additions & 17 deletions README.mkdn
Expand Up @@ -4,7 +4,7 @@ Data::SearchEngine::ElasticSearch - ElasticSearch support for Data::SearchEngine

# VERSION

version 0.15
version 0.17

# SYNOPSIS

Expand Down Expand Up @@ -93,20 +93,24 @@ for more details.
ElasticSearch wants an `index` and `type` for each Item that is indexed. It
is expected that you will populate these values in the item thusly:

my $item = Data::SearchEngine::Item->new(
id => $something,
values => {
index => 'twitter',
type => 'tweet',
# and whatever else
}
);
$dse->add($item);
my $item = Data::SearchEngine::Item->new(
id => $something,
values => {
index => 'twitter',
type => 'tweet',
# and whatever else
}
);
$dse->add($item);

## Filters

If you set multiple filters they will be ANDed together. If you want to change
this behavior then you can change the `filter_combiner` attribute to "or".
this behavior then you can supply an additional argument to the `query` method:

$dse->search($query, 'or');

This defaults to 'and'.

## Facets & Filters

Expand All @@ -115,11 +119,6 @@ If you use facets then any filters will be copied into the facet's

# ATTRIBUTES

## filter_combiner

Boolean used to combine filters. Should be either "and" or "or". Defaults to
and.

## servers

The servers to which we'll be connecting.
Expand Down Expand Up @@ -162,7 +161,7 @@ Cory G Watson <gphat@cpan.org>

# COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Cold Hard Code, LLC.
This software is copyright (c) 2012 by Cold Hard Code, LLC.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
6 changes: 5 additions & 1 deletion lib/Data/SearchEngine/ElasticSearch.pm
Expand Up @@ -326,6 +326,10 @@ sub search {
$options->{sort} = $query->order;
}

if($query->has_fields) {
$options->{fields} = $query->fields;
}

$options->{from} = ($query->page - 1) * $query->count;
$options->{size} = $query->count;

Expand Down Expand Up @@ -384,7 +388,7 @@ sub search {
sub _doc_to_item {
my ($self, $doc) = @_;

my $values = $doc->{_source};
my $values = $doc->{_source} || $doc->{fields};
$values->{_index} = $doc->{_index};
$values->{_version} = $doc->{_version};
return Data::SearchEngine::Item->new(
Expand Down

0 comments on commit 78cb625

Please sign in to comment.