Get all features from query

1165
1
Jump to solution
09-23-2020 02:53 PM
Vakhtang_Zubiashvili
Occasional Contributor III

Hi guys, Robert Scheitlin, GISP‌, Ken Buja‌,

Sorry, last question about that i marked as assumed answered and had to create new one.

 

I have autocomplete search widget generated from JQUERY.

 

Autocomplete works for some features ( it is street names ), but some features didn't appears in autocomplete, while if  i write in text field name of a street manually ( it should be full name, including , . ! etc) it finds the street.

When i check it on server side it does the same, if GEOMETRY is TRUE some features is missing, if FALSE again some features is still missing, no full features is response.

 

Here is a code i use: 

/Autocomplete

$(function () {
          var array = []
          queryTask = new QueryTask(myURL);
          query = new Query();
          query.returnGeometry = false;
          query.outFields = ["street_names"];
          query.where = "1=1";
          queryTask.execute(query).then(showResults);

          function showResults(results) {
            // Collect the results
            var resultItems = [];
            var resultCount = results.features.length;
            for (var i = 0; i < resultCount; i++) {
              var featureAttributes = results.features[i].attributes;
              for (var attr in featureAttributes) {
                // Convert the attribute to a string. Null Values create an extra comma which stops the widget from functioning.
                tags = String(featureAttributes[attr]);
                // push the attributes tothe blank array
                resultItems.push(tags);
              }
            }

            // Sort the array
            sorted = resultItems.sort()

            // Remove Duplicates
            var uniqueNames = [];
            $.each(sorted, function (i, el) {
              if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
            });

            // Set the varrible array
            array = uniqueNames

            // This is your AutoComplete Widget
            var availableTags = array;

            // Reference the div id which you want the autocomplete list to appear (in this case tag)(appear only 30 records)
            $("#searchInput").autocomplete({
              source: function (request, response) {
                var results = $.ui.autocomplete.filter(availableTags, request.term);

                response(results.slice(0, 20)); // მიუთითე რამდენი ჩანაწერი გინდა რომ გამოჩნდეს autocomplete- ში ერთდროულად.
              }
            });
          }
        });
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

The QueryTask is limited to the max amount of records that the service is configured to return (i.e. 1000 records by default). So if your service has more than 1000 or what ever the max records for your service is then your auto complete will not have all the records in it. In that case you will have to write code to handle the paging/multiple querytasks to get all your records.

View solution in original post

1 Reply
RobertScheitlin__GISP
MVP Emeritus

The QueryTask is limited to the max amount of records that the service is configured to return (i.e. 1000 records by default). So if your service has more than 1000 or what ever the max records for your service is then your auto complete will not have all the records in it. In that case you will have to write code to handle the paging/multiple querytasks to get all your records.