title: Querying a parameter that’s not an index on DynamoDb
body: <p>TableName : people</p>
  
  <p>id  | name  | age       | location</p>
  
  <p>id_1    | A     | 23        | New Zealand</p>
  
  <p>id_2    | B     | 12        | India</p>
  
  <p>id_3    | C     | 26        | Singapore</p>
  
  <p>id_4    | D     | 30        | Turkey</p>
  
  <p>keys: id -> hash and age->range</p>
  
  <p><strong>Question 1</strong></p>
  
  <p>I’m trying to execute a query: “Select * from people where age > 25”
  I can get it to work queries like “Select age from people where id = id_1 and age > 25” which is not what I need, just need to select all values. </p>
  
  <p>And if I don’t need age to be a range index, how should i modify my query params to just return the list of records matching the criterion: age > 25?</p>
  
  <p><strong>Question 2</strong></p>
  
  <p>AWS throws an error when either Lines 23 or 24-41 are commented.
  : Query Error:  ValidationException: Either the KeyConditions or KeyConditionExpression parameter must be specified in the request.
                  status code: 400, request id: []</p>
  
  <p>Is the KeyConditions/KeyConditionsExpressions parameter required? Does it mean that I cannot query the table on a parameter that's not a part of the index? </p>
  
  <pre><code>  func queryDynamo() {
          log.Println("Enter queryDynamo")
  
          svc := dynamodb.New(nil)
  
          params := &amp;dynamodb.QueryInput{
              TableName: aws.String("people"), // Required
              Limit:     aws.Long(3),
              // IndexName: aws.String("localSecondaryIndex"),
              ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
                  ":v_age": { // Required
                      N: aws.String("25"),
                  },
                  ":v_ID": {
                      S: aws.String("NULL"),
                  },
              },
              FilterExpression: aws.String("age &gt;= :v_age"),
  
              // KeyConditionExpression: aws.String("id = :v_ID and age &gt;= :v_age"),
              KeyConditions: map[string]*dynamodb.Condition{
                  "age": { // Required
                      ComparisonOperator: aws.String("GT"), // Required
                      AttributeValueList: []*dynamodb.AttributeValue{
                          { // Required
                              N: aws.String("25"),
                          },
                          // More values...
                      },
                  },
                  "id": { // Required
                      ComparisonOperator: aws.String("EQ"), // Required
                      // AttributeValueList: []*dynamodb.AttributeValue{
                      //  S: aws.String("NOT_NULL"),
                      // },
                  },
                  // More values...
              },
              Select:           aws.String("ALL_ATTRIBUTES"),
              ScanIndexForward: aws.Boolean(true),
          }
  
  //Get the response and print it out.
          resp, err := svc.Query(params) 
  
          if err != nil {
              log.Println("Query Error: ", err.Error())
          }
  
          // Pretty-print the response data.
          log.Println(awsutil.StringValue(resp))
      }
  </code></pre>