Git Product home page Git Product logo

elasticquent's People

Contributors

adamfairholm avatar dschniepp avatar grahamcampbell avatar k1ng440 avatar swhammack avatar yswery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elasticquent's Issues

Search Collection, not only Model

Hello.

From what I understand, a search can be applied to an Eloquent Model.

What about searching a collection of models?

Instead of doing, for example, only this: Article::search('my post');
I would also need to do this: Article::where('category','news')->search('my post');

Is there any chance that we can see this in the near future?

Cut a version

@adamfairholm - Is there any chance we can cut a composer version on this? We are using this in a HIGHLY critical system here at UrtheCast and don't want to take any chances with future changes that we have not tested.

Thanks!

Failed to access when host url with username:password

I am using facetflow.io, a hosted elasticsearch.
Their url have an API KEY prepend to the cluster url, such as:

https://apikey:@example.azure.facetflow.io

When I put in this URL to the config.hosts, facetflow returned error 401, authentication failed.

No problem when I was using aws elasticsearch, as they doesn't prepend any credential to the url.

So I wonder is this a problem with elasticquent or there are some problem with my server?

regards,

ElasticquentResultCollection.php always expects aggregations

Great work -- I've started using Elasticquent over the last day, and it works very nicely.

However, one issue I have is that ElasticquentResultCollection.php always expects aggregations to be returned from a search (line 26).

Most of the queries I'm doing at the moment don't need aggregations, and in order to prevent it throwing an error, I've had to change:

    $this->aggregations = $results['aggregations'];

to:

    $this->aggregations = isset($results['aggregations']) ? $results['aggregations'] : array();

How we can track every actions of user and not replace the stored documents?

Suppose in a case we need to store all actions of users that they do with a record, for example a user with id 100 update the record with id 12 and we store that in a document, after that the same user or any other user updated the same record, or delete this record now we should store new document, and not replace the first one.

Undefined index: aggregations

After last update, (it upgrades elasticsearch from 1.3.2 to 1.3.3) i'm getting this error:

Undefined index: aggregations

Also, I have tried to comment that line, then it shows results but without sorting.

Undefined index: aggregations

When I try to use search() I get the error: Undefined index: aggregations

Line 26 in /vendor/fairholm/elasticquent/src/ElasticquentResultCollection.php
$this->aggregations = $results['aggregations'];

creating index, put mapping and complex type storing

hello @adamfairholm , I am fairly new to laravel development so forgive me if I ask a stupid question.

  1. Elasticquent provide method for creating index and put mapping. my question is if I decided to use elasticquent instead of using elasticsearch API, when and where it should be called on my laravel application?
  2. when using elasticsearch api I can store complex structure by storing it in json formatted document. can I do this by using elasticquent? do I have to take other approach like using relationship?

thank you

About delete

I'm using Elasticquent to work with mysql. When I update and insert data, the addAllToIndex and reindex methods works great. But when I want to delete something, the data that I deleted is still there.

How can I delete data in elasticquent?

Indexing models question

Hi,

I am sorry about, maybe newbe question (I am beginner in this) but I am not sure how to use elasticquent...

so I did installed it into my app, elasticsearch also working fine, but not sure how to index data from model/s, tables? I have put

**use Elasticquent\ElasticquentTrait**;

class ModelName extends Eloquent {

    **use ElasticquentTrait;**

}

into models, and now I am confused what next..

Do I need some new route which I would fire up and then in that route app will execute ModelName::addAllToIndex() or some other way... And how to update index? is it going to do it by itself or I need something do execute with cron or something...

Tnx in advance for answer...

Model::searchByQuery() method

Hello,

When I use this function, the search returns only 10 records of a collection. After some hours of studying, I've read that is something to do with 'from' and 'size', it's something to do with pagination.

How can I get all records or rize the number of records (size) using elasticquent?

Querying by multiple form fields filter

Hi,

I'm new with Elastic. I would like to search by multiple form fields.

For example I have my form with: company_name, contacts.first_last_name.

In my Elastic structure I have company_name, contacts.firstname, contacts.lastname

I want search by name (concat firstname and lastname) but if I filled the company_name form field I want to search company_name AND firstname + lastname

I think it's working with concat field, but who to add other field ?

$clients = Client::searchByQuery([
    'multi_match' => [
        'query' => $request->get('first_last_name'),
        "type" => "cross_fields",
        'operator' => 'and',
        'fields' => [
            'contacts.firstname',
            'contacts.lastname',
        ]

    ]
]);

Btw, how to add some checkboxes to the query with Elasticquent ? Of course, firstname, lastname and company_name will be included in the query too. I think it's a complex filter :/

Thx.

Function putMapping - error

Hello everyone,

  1. When I use the function putMapping, I have a following error :
    MergeMappingException[Merge failed with failures {[mapper [document_col1] has different index_analyzer]}]". I specify that I already data in ElasticSearch.
  2. I try to remove mapping and index and then create index, put mapping and add index the document but the type and index specify in $mappingProperties are not correct. I do like following :
    Document::createIndex($shards = null, $replicas = null);
    Document::putMapping($ignoreConflicts = true);
    And foreach document :
    $document::addToIndex();

Could someone help me to solve this problem?

Elasticsearch wont apply not_analyzed into my mapping

My mappings look like this:

'ad_title' => [
'type' => 'string',
'analyzer' => 'standard'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_type' => [
'type' => 'integer',
'index' => 'not_analyzed'
],
'ad_state' => [
'type' => 'integer',
'index' => 'not_analyzed'
],

However when I view my mappings then 'index' => 'not_analyzed' wont show. I have made sure that I didnt have any existing data / remapped. Even made a new index. The 'index' => 'not_analyzed' will never show.

doing _mapping GET api call outputs my mapping as:

"testindex": {
"mappings": {
"ad_ad": {
"properties": {
"ad_city": {
"type": "integer"
},
"ad_id": {
"type": "long"
},
"ad_state": {
"type": "integer"
},
"ad_title": {
"type": "string",
"analyzer": "standard"
},
"ad_type": {
"type": "integer"
},

as you can see 'index' => 'not_analyzed' is not visible.

Asking on Stackoverflow someone posted me their output that looks like:

{
"hilden1": {
"mappings": {
"type1": {
"properties": {
"indexSpecified": {
"type": "string",
"index": "not_analyzed"
},
"regular": {
"type": "string"
}
}
}
}
}
}

As you can see "index": "not_analyzed" is visible.

So does Elasticquent dont support "index": "not_analyzed" ?

get aggregations as collection

Hello!
Im doing some queries in ES through laravel and I've made this query to remove duplicates :

$json = '{
"aggs":{
"dedup" : {
"terms":{
"field": "name"
},
"aggs":{
"dedup_docs":{
"top_hits":{
"size":1
}
}
}
}
}
}';

Now I need to get a collection. I've tried in this way but it doesn't work:

$search_params = array(
'index' => 'cif.observables-*',
'size' => 25000,
'search_type' => 'count'
);
$search_params['body'] = $json;
$cifs = new \Elasticquent\ElasticquentResultCollection($client->search($search_params), new \App\CustomModels\Cif);

In the blade page instead :
@foreach($cifs as $cif_element)

{{{ $cif_element->observable }}}
{{{ $cif_element->provider }}}
{{{ $cif_element->tags[0] }}}
{{{ $cif_element->otype }}}
{{{ $cif_element->confidence }}}
@Endforeach

I don't receive anything.. blank page. If I make the query without the aggregation it will work.

Thanks in advance,
Danilo

Document Search Method Feedback

Hello all - looking for some feedback on this.

Currently the way Elastiquent works is it uses the indexed source data in your Elasticsearch documents as the population data for your models. The whole idea behind using Elasticsearch is because it's super fast, so this way you are never hitting the database - you are bypassing that and using your indexed data only.

There are limitations to this, obviously - one being that you can only access data you have indexed, so you can't bust out relationships like you would when you are using Eloquent as you normally would. However, you can choose to index certain relationship data in your documents and search on those, allowing you to

So I'm wondering if Elastiquent needs functionality that allows you to hit the full database, using Elasticsearch as basically the search broker. So Elastiquent would search for the term and then do a FIELD query to limit to IDs, allowing you to do whatever you'd like to that query. It's a method that pushes Elasticsearch further back in the process but it may offer an easier path to flexibility for those who need it.

Adam

package is not working with composer - laravel

I am trying to install the package in composer by adding the following as stated:
"fairholm/elasticquent": "dev-master"
but I keep getting the following errors:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for fairholm/elasticquent dev-master -> satisfiable by fairholm/elasticquent[dev-master].
- fairholm/elasticquent dev-master requires illuminate/database ~4.2 -> no matching package found.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

That is my composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.",
"fzaninotto/faker": "^1.5",
"gloudemans/shoppingcart": "~1.3",
"elasticsearch/elasticsearch": "1.1.
",
"illuminate/database": "^5.1",
"fairholm/elasticquent": "dev-master"
},
"require-dev": {
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r "copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}

Any idea what is going wrong?!

Call to undefined function Elasticquent\config()

i use laravel 4.2 for my project
and setup Elasticquent
then run project i have erro Call to undefined function Elasticquent\config()
vendor\elasticquent\elasticquent\src\ElasticquentTrait.php
capture.
please help me

Sorting

Hi adamfairholm, thanks for providing this package. It gave me quite a quick entry into using Elasticsearch and Laravel compared to using Symfony 2 and Elastica which took me longer to wrap my head around.

In the documentation, under searching, you listed the parameters to the searchByQuery method and the last one was sort. I have however gone through your code and seen that the last parameter is offset and there is nowhere in the code where sorting is implemented. Is this an omission? How can I pass a sort query to elasticsearch via Elasticquent?

Thanks
Steve

Eager loading and chunking

Hi @adamfairholm,

I don't know if you would be up for merging this in, but I thought there were some things missing from this great package. Eager loading relationships and also indexing using chunking, more specifically the reindex and addAllToIndex not chunking. I have made these and some other changes on a fork. If you get some time please have a look and let me know if its something you would be happy to merge in and I will make a pull request.

https://github.com/clowdy/Elasticquent/tree/relations

Working with related models

I'm using it in a project, but I found that I would like to have indexed some information from relationships. I know this have to be sent to ElastichSearch formated like Documents and Subdocuments, so if I have a Product, what can I do to have Product.type in ElasticSearch instead to Product.type_id ? Being Product.type a string with the name of the Type and type_id the Id of the Type.

Question about boosted fields in Multi Match Query

Hi Adam,

Is it possible to apply boost on Individual fields with the caret (^) notation?
Like this sample:

{
  "multi_match" : {
    "query" : "this is a test",
    "fields" : [ "subject^3", "message" ] 
  }
}

Source: http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#CO47-1

If it's possible, how to do this with your package?
Something like this?

$client = new \Elasticsearch\Client();

$params = [
    'index' => 'default',
    'type'  => 'books'
    'body' => [
        'multi_match' => [
            'query' => 'Moby Dick',
            'fields' => ['title^3', 'author']
        ]
    ]
];

$collection = new \Elasticquent\ElasticquentResultCollection($client->search($params), new Book);

The title field is three times as important as the author field.

Cheers,
Tortue Torche

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.