0

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 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

in order to filter group ids i have to index them or keep as not_analyzed , if i add lot of details indexed then it will cause any problem.I mean the size of index will effect performance
You can put group_ids as an array in user mapping. This will require some extra space but you need to trade space with performance. The difference of space will not be that much as its just id. Size of index does not effect performance for your use case, but if your index becomes that big then you will have to keep different indices for these things, which I think you will never need. I have been using ES to index data of around 100 GB without any performance issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.