# |
Jul 10th 2018, 09:19 |
james.phillips |
thanks |
# |
Jul 10th 2018, 09:19 |
josbeir |
what do you mean @james.phillips |
# |
Jul 10th 2018, 09:19 |
josbeir |
dep tree: cakephp/elasticsearch => ruflin/elastica => elasticsearch/elasticsearch |
# |
Jul 10th 2018, 09:18 |
james.phillips |
lol confused... does the plugin auto save data to ES and query it? |
# |
Jul 10th 2018, 09:18 |
neon1024 |
Leveraging the ORM will be super handy, as writing your own queries in json is a PITA |
# |
Jul 10th 2018, 09:18 |
neon1024 |
I implemented their own library and it was kinda hard work |
# |
Jul 10th 2018, 09:18 |
josbeir |
so you can use that too if you want to write more complex stuff |
# |
Jul 10th 2018, 09:17 |
josbeir |
it uses elastica |
# |
Jul 10th 2018, 09:17 |
james.phillips |
better than using something liek http://elastica.io/getting-started/storing-and-indexing-documents.html? |
# |
Jul 10th 2018, 09:17 |
josbeir |
its pretty good :slightly_smiling_face: |
# |
Jul 10th 2018, 09:17 |
josbeir |
yes |
# |
Jul 10th 2018, 09:17 |
james.phillips |
is the es plugin the best way to add elasticsearch to cakephp? |
# |
Jul 10th 2018, 09:16 |
josbeir |
i'm not sure authentication is currently working in the ES plugin but it probably can be added in the connection class |
# |
Jul 10th 2018, 09:16 |
james.phillips |
Im not sure...Authorization: Bearer is what i need to set i think |
# |
Jul 10th 2018, 09:16 |
neon1024 |
Then when I make the request, I’ll read from Configure |
# |
Jul 10th 2018, 09:16 |
neon1024 |
I tend to use `bootstrap.php` and use `Configure::write()` |
# |
Jul 10th 2018, 09:15 |
josbeir |
@james.phillips i'm guessing its for x-pack auth? |
# |
Jul 10th 2018, 09:15 |
james.phillips |
Yep where do you put the elastic search api key they give u?! |
# |
Jul 10th 2018, 09:15 |
james.phillips |
i have 'elastic' => [ 'className' => 'Cake\ElasticSearch\Datasource\Connection', 'driver' => 'Cake\ElasticSearch\Datasource\Connection', 'host' => 'https://host-7djrft.api.swiftype.com/api/as/v1/engines/xxxx/', 'port' => 9200, 'index' => '', in app.php under datasources |
# |
Jul 10th 2018, 09:14 |
neon1024 |
Do you mean this? https://github.com/cakephp/elastic-search#defining-a-connection |
# |
Jul 10th 2018, 09:14 |
james.phillips |
I have Plugin::load('Cake/ElasticSearch', ['bootstrap' => true]); in bootstrap |
# |
Jul 10th 2018, 09:14 |
neon1024 |
You’ll want to write a new authentication adapter for your web service |
# |
Jul 10th 2018, 09:14 |
james.phillips |
Its for elastic search... |
# |
Jul 10th 2018, 09:13 |
neon1024 |
The configuration of your data source has nothing to do with Authentication |
# |
Jul 10th 2018, 09:13 |
neon1024 |
Don’t do that. |
# |
Jul 10th 2018, 09:13 |
james.phillips |
does anyone know who to set api auth under Datasources in app.php? |
# |
Jul 10th 2018, 09:11 |
neon1024 |
Perhaps table_alias and primary_key need to be a composite key? |
# |
Jul 10th 2018, 09:11 |
josbeir |
so your companies join in Users is also joined in your custom getPermissions query |
# |
Jul 10th 2018, 09:10 |
neon1024 |
The above SQL is also taking into account that in my CompaniesTable, the UserPermissions association has a condition set of `'conditions' => ['UserPermissions.table_alias' => 'Companies'],` which isn’t being applied to the join either |
# |
Jul 10th 2018, 09:10 |
josbeir |
thats indeed weird |
# |
Jul 10th 2018, 09:01 |
neon1024 |
So I feel like I’m stuck between a bad solution and a hack |
# |
Jul 10th 2018, 09:01 |
neon1024 |
File uploaded https://cakesf.slack.com/files/U1BT622HW/FBP0U1BM4/sql.sql / https://slack-files.com/T053DPNCM-FBP0U1BM4-50626cdba1 |
# |
Jul 10th 2018, 09:01 |
neon1024 |
You can contain them, without the left join, but then the query lacks the table alias in the join |
# |
Jul 10th 2018, 09:00 |
neon1024 |
File uploaded https://cakesf.slack.com/files/U1BT622HW/FBM2YRZ7S/containing_associations.php / https://slack-files.com/T053DPNCM-FBM2YRZ7S-7c369fec17 |
# |
Jul 10th 2018, 09:00 |
neon1024 |
Which means using the belongsTo through UserPermissions becomes really hard |
# |
Jul 10th 2018, 09:00 |
neon1024 |
..and it’s taking that condition for the query |
# |
Jul 10th 2018, 09:00 |
neon1024 |
All I can think is that Cake is processing the belongsTo association by running a query for Companies to build the association |
# |
Jul 10th 2018, 08:59 |
neon1024 |
Why would the conditions from the UserPermissions table be applied to a query for Companies?! |
# |
Jul 10th 2018, 08:59 |
neon1024 |
Which to me, seems totally illogical |
# |
Jul 10th 2018, 08:59 |
neon1024 |
However if I uncomment the above conditions in the UserPermissions association, I get a failed query for Companies with a where condition of `['UserPermissions.table_alias' => 'Companies']` |
# |
Jul 10th 2018, 08:58 |
neon1024 |
It even uses left join by default |