ElasticUI
ElasticUI copied to clipboard
search triggered on page loading
hi,
the searchbox directive triggers search query on page loading is there anyway to disable triggering the search?
Good suggestion, will keep this open for the next release!
:+1:
fixed, use ng-init to set indexVM.autoLoad=false
:100:
Hello Yousef,
It seems that the autoLoad not working. I have tested it and modified the value in indexController to set it false but despite of that it is triggering the search .
Can you provide a jsfiddle or similar of the issue?
Actually, when i tested it in codepen it works.
But in my case, it triggers at page load, this my indexVM:
{
"host": null,
"query": null,
"sort": {
"_score": {
"order": "desc"
}
},
"aggregationProviders": {
"objects": [
null,
null,
null,
null,
null
]
},
"filters": {
"ejsObjects": [
{
"term": {
"publish": "true"
}
},
{
"range": {
"price": {
"from": 1000,
"to": 10000000
}
}
},
{
"range": {
"year": {
"from": 1950,
"to": 2015
}
}
},
{
"range": {
"mileage": {
"from": 0,
"to": 10000000
}
}
},
{
"range": {
"power": {
"from": 10,
"to": 1000
}
}
}
],
"jsonObjects": [
"{\"term\":{\"publish\":\"true\"}}",
"{\"range\":{\"price\":{\"from\":1000,\"to\":10000000}}}",
"{\"range\":{\"year\":{\"from\":1950,\"to\":2015}}}",
"{\"range\":{\"mileage\":{\"from\":0,\"to\":10000000}}}",
"{\"range\":{\"power\":{\"from\":10,\"to\":1000}}}"
]
},
"highlight": null,
"loaded": true,
"page": 1,
"index": "cars",
"loading": false,
"pageCount": 2,
"pageSize": 10,
"results": {
"took": 4,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"hits": {
"total": 15,
"max_score": 1,
"hits": [
{
"_index": "cars",
"_type": "ads",
"_id": "98",
"_score": 1,
"_source": {
"id": 98,
"category": "Voiture",
"type": "Citadine",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>lkjdsflk jsdf lsdkjf sldkjf sldkjlsdkjfsdlkj sdlfkj slkfjsdlkjsd</p>",
"warranty": true,
"metal": true,
"price": 123214,
"power": 123,
"year": 1966,
"mileage": 123,
"color": "#FC809B",
"created": "20150521T161927+0100",
"updated": "20150521T161927+0100",
"title": "AUDI A3 1966",
"publish": true,
"hasImages": true,
"door": "5 portes",
"options": [
"Detecteur de pluie",
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"Radio cassette",
"ABS",
"ESP",
"Jantes Alu",
"Chassis sportif"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/98/77_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/98/77.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "100",
"_score": 1,
"_source": {
"id": 100,
"category": "Voiture",
"type": "Citadine",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>amine</p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 123,
"year": 1959,
"mileage": 1324,
"color": "#FC809B",
"created": "20150521T162549+0100",
"updated": "20150521T162549+0100",
"title": "AUDI A3 1959",
"publish": true,
"hasImages": true,
"door": "4 portes",
"options": [
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"ABS",
"Jantes Alu",
"Chassis sportif"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/100/79_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/100/79.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "111",
"_score": 1,
"_source": {
"id": 111,
"category": "Voiture",
"type": "4x4",
"make": "BMW",
"model": "318IS",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>emlkzemlkf </p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 671,
"year": 1958,
"mileage": 12334,
"color": "#CEA1E1",
"created": "20150524T134718+0100",
"updated": "20150524T134718+0100",
"title": "BMW 318IS 1958",
"publish": true,
"hasImages": false,
"door": "5 portes",
"viewCount": 0,
"options": [
"Detecteur de pluie",
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"Radio cassette",
"ABS",
"ESP",
"Jantes Alu",
"Chassis sportif"
],
"imageThumbsUrls": [],
"imageUrls": [],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "106",
"_score": 1,
"_source": {
"id": 106,
"category": "Voiture",
"type": "Break",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>amine </p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 123,
"year": 1959,
"mileage": 134,
"color": "#FFADED",
"created": "20150522T171719+0100",
"updated": "20150522T171719+0100",
"title": "AUDI A3 1959",
"publish": true,
"hasImages": true,
"door": "5 portes",
"options": [
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"ABS"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/106/84_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/106/84.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "104",
"_score": 1,
"_source": {
"id": 104,
"category": "Voiture",
"type": "4x4",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>dfs fsd sd sdf fsdf sd fsd fdsd fsd </p>",
"warranty": true,
"metal": true,
"price": 2134,
"power": 123,
"year": 1961,
"mileage": 1234,
"color": "#FC809B",
"created": "20150522T170758+0100",
"updated": "20150522T224859+0100",
"title": "AUDI A3 1961",
"publish": true,
"hasImages": true,
"door": "4 portes",
"options": [
"Detecteur de lumiere",
"Ordinateur de bord",
"Phare xenon",
"Radio CD",
"GPS",
"Regulateur de vitesse",
"Climatisation",
"Alarme",
"Anti-neige"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/104/91_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/96_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/93_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/92_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/95_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/82_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/94_thumb.jpg",
"http://www.mapple.ma/assets/ad/104/97_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/104/91.jpg",
"http://www.mapple.ma/assets/ad/104/96.jpg",
"http://www.mapple.ma/assets/ad/104/93.jpg",
"http://www.mapple.ma/assets/ad/104/92.jpg",
"http://www.mapple.ma/assets/ad/104/95.jpg",
"http://www.mapple.ma/assets/ad/104/82.jpg",
"http://www.mapple.ma/assets/ad/104/94.jpg",
"http://www.mapple.ma/assets/ad/104/97.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "102",
"_score": 1,
"_source": {
"id": 102,
"category": "Voiture",
"type": "Monospace",
"make": "AUDI",
"model": "A3",
"fuel": "Diesel",
"transmission": "Manuelle",
"description": "<p>kjh kjhkj hk jhkjh jkh kjh kjh kjhkj hkjh k</p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 123,
"year": 1961,
"mileage": 1234,
"color": "#FFADED",
"created": "20150522T163843+0100",
"updated": "20150522T163848+0100",
"title": "AUDI A3 1961",
"publish": true,
"hasImages": true,
"door": "5 portes",
"options": [
"Direction assistée",
"Toit ouvrant",
"Radio cassette"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/102/81_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/102/81.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "96",
"_score": 1,
"_source": {
"id": 96,
"category": "Voiture",
"type": "Citadine",
"make": "ACURA",
"model": "CL_MODELS",
"fuel": "Essence",
"transmission": "Automatique",
"description": "<p> sd fd ds ds ds sddfsf sdf sdf ds fsd f</p>",
"warranty": true,
"metal": true,
"price": 12345,
"power": 123,
"year": 1950,
"mileage": 12345,
"color": "#FFADED",
"created": "20150519T111505+0100",
"updated": "20150519T111505+0100",
"title": "ACURA CL_MODELS 1950",
"publish": true,
"hasImages": true,
"door": "2 portes",
"viewCount": 13,
"options": [
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"ABS"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/96/72_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/96/72.jpg"
],
"civility": "Mr",
"firstName": "prenom",
"name": "nom",
"contactEmail": "[email protected]",
"contactAddress": "12 Rue Saint Saens, Casablanca, Maroc",
"contactCity": "Casablanca",
"location": "33.5919608,-7.591068299999961",
"telephone": "0809090909",
"isdealer": false
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "95",
"_score": 1,
"_source": {
"id": 95,
"category": "Voiture",
"type": "Citadine",
"make": "AUDI",
"model": "A3",
"fuel": "Essence",
"transmission": "Automatique",
"description": "<p>fs fds ffsdf sd fds sdsd s fsd fsd sdf sdf</p>",
"warranty": true,
"metal": true,
"price": 123554,
"power": 123,
"year": 1957,
"mileage": 12345,
"color": "#6798E6",
"created": "20150519T010508+0100",
"updated": "20150519T010508+0100",
"title": "AUDI A3 1957",
"publish": true,
"hasImages": true,
"door": "4 portes",
"viewCount": 0,
"options": [
"Sieges retractable",
"Anti-neige",
"Aide au stationnement",
"Airbags"
],
"imageThumbsUrls": [
"http://localhost/assets/ad/95/71_thumb.jpg"
],
"imageUrls": [
"http://localhost/assets/ad/95/71.jpg"
],
"civility": "Mr",
"firstName": "prenom",
"name": "nom",
"contactEmail": "[email protected]",
"contactAddress": "12 Rue Saint Saens, Casablanca, Maroc",
"contactCity": "Casablanca",
"location": "33.5919608,-7.591068299999961",
"telephone": "0809090909",
"isdealer": false
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "97",
"_score": 1,
"_source": {
"id": 97,
"category": "Voiture",
"type": "Citadine",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>ljlkjsdf lkj sdlkfjdslkfjdslkjf lkjsd flkjdslfk</p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 132,
"year": 1957,
"mileage": 123142,
"color": "#FFADED",
"created": "20150521T161355+0100",
"updated": "20150521T161355+0100",
"title": "AUDI A3 1957",
"publish": true,
"hasImages": true,
"door": "4 portes",
"options": [
"Detecteur de pluie",
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"Radio cassette",
"ABS",
"ESP",
"Jantes Alu",
"Chassis sportif"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/97/76_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/97/76.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
},
{
"_index": "cars",
"_type": "ads",
"_id": "99",
"_score": 1,
"_source": {
"id": 99,
"category": "Voiture",
"type": "Berline",
"make": "AUDI",
"model": "A3",
"fuel": "Hybride",
"transmission": "Manuelle",
"description": "<p>amine</p>",
"warranty": true,
"metal": true,
"price": 1234,
"power": 123,
"year": 1960,
"mileage": 1234,
"color": "#FC809B",
"created": "20150521T162357+0100",
"updated": "20150521T162357+0100",
"title": "AUDI A3 1960",
"publish": true,
"hasImages": true,
"door": "5 portes",
"options": [
"Detecteur de pluie",
"Direction assistée",
"Toit ouvrant",
"4 roues motrices",
"Radio cassette",
"ABS",
"ESP",
"Jantes Alu",
"Chassis sportif"
],
"imageThumbsUrls": [
"http://www.mapple.ma/assets/ad/99/78_thumb.jpg"
],
"imageUrls": [
"http://www.mapple.ma/assets/ad/99/78.jpg"
],
"civility": "Mr",
"firstName": "master",
"name": "mind",
"contactEmail": "[email protected]",
"contactAddress": "Ministère des Habous, Khouribga, Maroc",
"contactCity": "Marrakech",
"location": "-8.008889,31.63",
"telephone": "3333333333",
"isdealer": true,
"dealerAddress": "Ministère des Habous, Khouribga, Maroc",
"dealerCompany": "mind",
"dealerTitle": "master",
"dealerLogo": "http://www.mapple.ma/assets/logo/2/logo_200x150.jpg"
}
}
]
},
"aggregations": {
"filtered_options": {
"doc_count": 15,
"options": {
"doc_count_error_upper_bound": 2,
"sum_other_doc_count": 41,
"buckets": [
{
"key": "Toit ouvrant",
"doc_count": 13
},
{
"key": "ABS",
"doc_count": 12
},
{
"key": "Direction assistée",
"doc_count": 12
},
{
"key": "4 roues motrices",
"doc_count": 11
},
{
"key": "Radio cassette",
"doc_count": 8
}
]
}
},
"filtered_price70": {
"doc_count": 15,
"price70": {
"value": 18321.4
}
},
"filtered_price60": {
"doc_count": 15,
"price60": {
"value": 1234
}
},
"filtered_price50": {
"doc_count": 15,
"price50": {
"value": 123554
}
},
"filtered_model": {
"doc_count": 15,
"model": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "A3",
"doc_count": 11
},
{
"key": "318IS",
"doc_count": 1
},
{
"key": "CL_MODELS",
"doc_count": 1
},
{
"key": "DB9",
"doc_count": 1
},
{
"key": "LEGEND",
"doc_count": 1
}
]
}
}
}
},
"error": null,
"autoLoad": false
}
Here is the request triggered search triggering at pageLoad.
May be i'm misconfigured elasticui or
In my index.html, i have:
<body eui-index="'cars'" >
<span ng-init="indexVM.autoLoad=false"></span>
And the search page is a view (ui-router state).
Here is the indexVM in rootScope.
Can you try putting ng-init="indexVM.autoLoad=false" on the same element as eui-index? (
)
It didn't work, i think the trigger is the the use of eui-filter with eui-enabled= true.
I am checking this theory.
Youssef,
I have tested a hack and it works: it consists of adding this tests if(!angular.isUndefined(_this.indexVM.query) && _this.indexVM.query != null) in $watch / $watchCollections inside IndexController constructor.
There is a special case for watch on indexVM.query:
$scope.$watch('indexVM.query', function (newValue, oldValue) {
// we launch the search when the query is not null except the case when we query with
// an empty string after we had already launched a search
// ex: query with string1 we got result after we remove the key and launch the search
// we should get all the results
if (oldValue != null && newValue == null) {
return _this.search();
}
if ( _this.indexVM.query != null) {
return _this.search();
}
});
Hi!
Thanks for the code and digging in to this.
My suspicion is the root cause is the timeout described in issue #10. I think your app is not configured yet after 200ms, causing the following scenario:
- app is partially loaded, triggers the loaded() timeout after 200ms
- Therefor, indexVM.loaded is set to true
- One of your directives triggers a watch in IndexController, calling search()
- Because indexVM.loaded has been set to true, the search will pass
Could you try setting the timeout to a higher number? If so, we'd be better off fixing #10 instead of applying a temp. fix for your issue indirectly caused by #10
Yes, it's the case i changed it to 2000 ms and the search is not triggered.
Hi YousefED,
First of all, great job on the ElasticUI..!!
query: is there a way to pass 'type' information along with 'eui-index' ?
I have an index and multiple types under the index. I'd like to fetch data only from a specific 'type'. I've checked IIndexScope.ts and IIndexController.ts files, didn't find any type info there. Is it possible to add this feature or can you let me know if there is a work around?
Thanks, Pavan