This repository has been archived by the owner on Feb 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 243
Major overhaul #40
Closed
+573
−45
Closed
Major overhaul #40
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c79edd5
Remove asterisk from search query, this is heavy on ES and prevents s…
afd454a
Use filter term instead of query for filters, it's faster and score i…
5bf1267
Update test to match query changes.
8a9aa65
Add phpStorms idea folder to gitignore.
f503fe9
Verify that models exists for all returned keys before mapping result…
f0b7a84
Merge pull request #1 from thomasjsn/query-experiment
thomasjsn dfc5821
Specify query method and parameters in config, or in searchable model.
3524850
Add sorting.
c61b31e
Merge remote-tracking branch 'origin/master' into query-experiment
ac304bf
Allow each model to use different indices, add console command for cr…
c2ae535
Merge pull request #2 from thomasjsn/query-experiment
thomasjsn 246c96d
Make tests pass.
9d70fc0
Include orderBy in test.
19e6dc7
Merge branch 'master' of github.com:thomasjsn/laravel-scout-elastic
41feba7
Added necessary documentation for new features.
kkomelin e438be9
Added some formatting.
kkomelin ed91805
Merge pull request #3 from kkomelin/master
thomasjsn c347d83
Rename elastic:make-index command to make-indices, add line at end of…
eec00a4
Update README.md
thomasjsn 798b142
Add some explanations in the config file.
2044149
Remove PHP 7 null coalescing operator.
fb73888
Add some color to readme code blocks
thomasjsn 8fed9de
Add elastic searchable interface.
8ac1653
Ask before overwriting existing indices.
4cccd7a
Update composer.json
thomasjsn 46864e9
Update README.md
thomasjsn e75652e
Update composer.json
thomasjsn 48a9f95
Update README.md
thomasjsn ed9577e
Update .travis.yml
thomasjsn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ composer.lock | |
.DS_Store | ||
Thumbs.db | ||
/phpunit.xml | ||
/build | ||
/build | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Elasticsearch host | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Your Elasticsearch servers go here, by default it will use localhost. But | ||
| you can change that here or in your environment file. | ||
*/ | ||
|
||
'hosts' => [ | ||
env('ELASTICSEARCH_HOST', 'http://localhost'), | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Queries and query parameters | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you can specify different search methods, and their parameters. | ||
| The scout "search" method uses the default query type, with its parameters. | ||
| If you use the "elasticSearch" method you can specify the query type and | ||
| override the search parameters when performing the search. | ||
| | ||
*/ | ||
|
||
'queries' => [ | ||
'default' => 'query_string', | ||
|
||
'query_string' => [ | ||
'default_operator' => "AND" | ||
], | ||
'multi_match' => [ | ||
'fields' => '_all', | ||
'fuzziness' => 'auto' | ||
] | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Elasticsearch indices | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you can define your indices, with separate settings and mappings. | ||
| You can choose which index a model belongs to my overriding the | ||
| searchableWithin() method. A model will, by default, belong to the first | ||
| index listed here. | ||
| | ||
| You may specify your mappings in the model if you like that approach, | ||
| just make a static method, e.g. mapping() and refer to it here, like: | ||
| | ||
| 'mappings' => [ | ||
| 'articles' => \App\Article::mapping() | ||
| ] | ||
| | ||
*/ | ||
|
||
'indices' => [ | ||
|
||
'laravel' => [ | ||
'settings' => [ | ||
"number_of_shards" => 1, | ||
"number_of_replicas" => 0, | ||
], | ||
'mappings' => [ | ||
'articles' => [ | ||
'title' => [ | ||
'type' => 'string' | ||
] | ||
] | ||
] | ||
], | ||
|
||
'another_index' => [ | ||
'settings' => [ | ||
"number_of_shards" => 1, | ||
"number_of_replicas" => 0, | ||
], | ||
'mappings' => [ | ||
'articles' => [ | ||
'title' => [ | ||
'type' => 'string' | ||
] | ||
] | ||
] | ||
] | ||
|
||
] | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace ScoutEngines\Elasticsearch\Console; | ||
|
||
use Elasticsearch\ClientBuilder; | ||
use Illuminate\Console\Command; | ||
|
||
class ElasticIndicesCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'elastic:indices'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Show Elasticsearch indices (cat command)'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$host = config('elasticsearch.hosts'); | ||
|
||
$client = ClientBuilder::create()->setHosts($host)->build(); | ||
|
||
$indices = $client->cat()->indices(); | ||
|
||
if(count($indices) > 0) { | ||
$headers = array_keys(current($indices)); | ||
$this->table($headers, $indices); | ||
} else { | ||
$this->warn('No indices found.'); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can have the configuration inside scout.php I would like to have every driver config in the same scout config file.