0
votes

we have a social application where user can make group under some specific categories.User will have user Education , Certification ,location etc. i want to search user on the basis of location,education etc. similarly search group based on categories . i want to use Elasticsearch

this is user mapping

"userData" : {
        "dynamic" : "true",
        "properties" : {
          "allSuggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50
          },
          "email" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "firstName" : {
            "type" : "string"
          },
          "gender" : {
            "type" : "object",
            "enabled" : false
          },
          "id" : {
            "type" : "string"
          },
          "isActive" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "lastName" : {
            "type" : "string"
          },
          "location" : {
            "properties" : {
              "country" : {
                "type" : "string",
                "index" : "not_analyzed"
              },
              "region" : {
                "type" : "string"
              }
            }
          },
          "mId" : {
            "type" : "object",
            "enabled" : false
          },
          "profilePic" : {
            "type" : "object",
            "enabled" : false
          },
          "profileStatus" : {
            "type" : "object",
            "enabled" : false
          },
          "status" : {
            "type" : "object",
            "enabled" : false
          },
          "userId" : {
            "type" : "object",
            "enabled" : false
          },
          "userSuggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50
          }
        }
      }

​group model

"groupData" : {
        "dynamic" : "true",
        "properties" : {
          "allSuggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50
          },
          "cDate" : {
            "type" : "object",
            "enabled" : false
          },
          "categoryId" : {
            "type" : "integer"
          },
          "groupId" : {
            "type" : "object",
            "enabled" : false
          },
          "groupName" : {
            "type" : "string"
          },
          "groupPic" : {
            "type" : "object",
            "enabled" : false
          },
          "groupStatus" : {
            "type" : "object",
            "enabled" : false
          },
          "groupSuggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50
          },
          "isActive" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "mId" : {
            "type" : "object",
            "enabled" : false
          }
        }
      }

​the problem is that how can i say user is a member of the group. search members in a particular group

should i add the education details with the userData itself as nested or parent child.

Or it is difficult to handle social relations in Elasticsearch?

1

1 Answers

0
votes

the problem is that how can i say user is a member of the group

For this you can have an array of group ids in user mapping itself and then use term filter to filter the group id.

search members in a particular group

This can be done using the above method itself.

should i add the education details with the userData itself as nested or parent child.

Education details should be a part of the user mapping itself. This can be made using nested array. Using parent child relationships for this will be a overkill.